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

Other Parts Discussed in Thread: CC2540

Hi everyone,

 

am new to IAR compiler and cc2540.

i completed usart communication..now am trying to interface ANALOG sensor using ADC pin

of cc2540 but am not getting proper output..:(

here am attaching my code pls check and let me know my mistakes..    

PROGRAM:

void adc()
{

unsigned int adc_result;
CLKCONCMD = (CLKCONCMD & (0x40 | (0x07)));
while (CLKCONSTA & 0x40 ); // Wait until clock source has changed

ADCCON1 = 0x00;
ADCCON2 = 0x00;
P0SEL &= ~0x10; /* Set pin (sample) as GPIO */
P0DIR &= ~0x10; /* Set pin as input*/
P0INP |= 0x10;
APCFG |= 0x10; /* configure ADC on pin4*/

ADCCON1 |= 0x30;

ADCCON2 |= 0xb4;

//ST=1;
ADCCON1 |= 0x40;

tv = ADCL;
tv |= (((unsigned short) ADCH) << 8);
tv >>= 4 ;
lv = tv;
}