romel_emperado
Advanced Member level 2
- Joined
- Jul 23, 2009
- Messages
- 606
- Helped
- 45
- Reputation
- 132
- Reaction score
- 65
- Trophy points
- 1,318
- Location
- philippines
- Activity points
- 6,061
correction of my previous code for aDC..
This is the right code for left justified setting... . I just noticed Im discarding the MSB of my ADRESH..
**broken link removed**
This is the right code for left justified setting... . I just noticed Im discarding the MSB of my ADRESH..
**broken link removed**
PHP:
unsigned int adc_read()
{
unsigned int adc_result;
ADCON0 = 0x00;
ADCON0bits.ADON = 1; //turn on adc
ADCON0bits.GO_DONE = 1; //start converstion
while(GO_DONE); //wait for converstion to finish
ADCON0bits.ADON = 0; //turn off adc
adc_result = ADRESH;
adc_result = (adc_result << 2) | (ADRESL>>6);
return adc_result;
}