This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540 ADC configuration

Hi can some one please look at my code and see what i am doing wrong. I'm trying to connect an analogue input to PIN1 of test pins (P0_6) and converting it using the ADC. But don't get any results when i try to read the battery level on Btool.


P0SEL = 0; // Configure Port 0 as GPIO
P1SEL = 0x40; // Configure Port 1 as GPIO, except P1.6 for peripheral function for buzzer
P2SEL = 0; // Configure Port 2 as GPIO

APCFG = 0x40; //set AIN6 as analogue input
P0DIR = 0xBC; // Port 0 pins P0.0 and P0.1 as input (buttons), AIN6 as input
// all others (P0.2-P0.7) as output
P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output
P2DIR = 0x1F; // All port 1 pins (P2.0-P2.4) as output

P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons)
P1 = 0; // All pins on port 1 to low
P2 = 0; // All pins on port 2 to low

// Configure ADC and perform a read
HalAdcSetReference( HAL_ADC_REF_125V );
adc = HalAdcRead( HAL_ADC_CHN_AIN6, HAL_ADC_RESOLUTION_10 );

And can some one tell me exactly how do i connect my analogue input. I might be connecting it incorrectly