ADC initialisation procedure for LPC1768 ???

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC initialisation procedure for LPC1768 ???

371 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Sukruth on Tue Sep 03 23:19:06 MST 2013
Hi,
I have a  question regarding ADC initialization, will the following lines allow me to read and measure the input voltage??? OR do I need to include something else?

LPC_SC->PCONP |= (1<<15); /* power up GPIO */
LPC_SC->PCONP |= (1<<12); /*Power up ADC*/
LPC_PINCON->PINSEL1 |= ((1<<16));// P0.24 = ADC0.1
LPC_PINCON->PINSEL1 |= ((1<<17)|(1<<19)); /*Neither pull-up/pull-down resistor*/


ADC_Init(LPC_ADC, 10000);
ADC_IntConfig(LPC_ADC,ADC_ADINTEN1,ENABLE);
ADC_ChannelCmd(LPC_ADC,ADC_CHANNEL_1,ENABLE);
ADC_BurstCmd(LPC_ADC, ENABLE);

ADC_StartCmd(LPC_ADC,ADC_START_CONTINUOUS);
for(i=0;i<1500000;i++) // for delay, but  is this required???



ADCDone = ADC_ChannelGetData(LPC_ADC,ADC_CHANNEL_1);

now suppose the ADC is initialized, and say I will be reading a Voltage value between 0-3.3V and I have to put switch cases based on this value, what will be the ADCDone units will it be in hex (uint16_t 0 to 65,536 ) or will it be in decimal values ???
.

can i use if condition to activate some commands using the ADCDone value i get as input from a potentiometer?

            if (ADCDone >=... )
            {
// Comand 1
            }
           
            else if (ADCDone >=... )
            {
// Comand 2
            }
            else if (ADCDone >=... )
            {
// Comand 3
            }
            else
            {
// Comand 4
    }
            end


Thanks,
Labels (1)
0 Kudos
0 Replies