Other Parts Discussed in Thread: CC2540
Hello,
I have trouble with reading an input on pin P0_6 and am wondering if someone sees something obvious that I am doing wrong.
I will paste the code snippets below. The reference voltage is on P0_7.
P0SEL = 0
P0DIR = 0;
APCFG = BIT7|BIT6|BIT2|BIT1|BIT0;
The above initialization is done once after reset.
Then, whenever in need to read the input, using channel number 6:
#define REF_VOLTAGE 1 // External on AIN7 pin
#define DECIMATION_RATE 3
ADCCON3 = (REF_VOLTAGE << 6) | (DECIMATION_RATE << 4) | 6;
// Wait for completion
while( !(ADCCON1 & BIT7) );
int16 adc_result;
adc_result = (ADCH << 8);
adc_result |= ADCL;
Is there anything wrong with the above sequence?
Thanks,
Marius Matioc