Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years ago.
ADC initialisation procedure for LPC1768 ???
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,
2 Answers
12 years ago.
Why don't you use the Analogin class ? The mbed lib is doing all initialisation for you.