We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi I how to extract the data for multiple input to adc port in lpc2138 . Here is the code for initialization of the adc and tell me how to extract the data for both the adc
void adc_ini(void) { PINSEL1 = 0X05000000; //pin 13 p0.28 and p0.29 adc 0 channel 1 and 2 PCONP |= 0X00001000; //select adc 0 bit 12 AD0CR &= 0X00000000; AD0CR |= 0X00200206; // WITH PCLK 12/(2+1)=4MHZ ADC0 CHANNEL 1 and 2 PIN 13 and 14 AD0INTEN &= 0x00000000; //Completion of a conversion on ADC channel 0 will not generate an interrupt. } void adc_data(void) { AD0CR |= 0x01000000; /* Start A/D Conversion */ while((AD0DR & 0x80000000)==0); //until bit 31 is high (DONE) val = AD0DR; //read a/d data register adc_val = ((val >> 6) & 0x3FF); // Extract AD result }
How to modify for extracting the data from both the data register ?
Thanks in advance
But the code you posted is meaningless.
There will not be any value in AD0DR2 unless you request that the ADC should perform a conversion of that channel. Where are your code that requests a read of analog channel 2?
You can't write code that expects that the "DONE" bit of AD0DR2 should be set unless you have first ordered a conversion for that channel.
You do:
AD0CR |= 0x01000000;
but that will not convert a lot of channels unless you run full hardware conversion mode.
Hi
How to set the hardware conversion mode ? The thing is i need to convert two different analog input to digital simultaneously.
Thanks
What part of the user manual text is it that you do not understand?
You feel the text is unclear? What part of it?
select bit in ADCR Selects which of the AD0.7:0/AD1.7:0 pins is (are) to be sampled and converted. For AD0, bit 0 selects Pin AD0.0, and bit 7 selects pin AD0.7. In software-controlled mode, only one of these bits should be 1. In hardware scan mode, any value containing 1 to 8 ones. All zeroes is equivalent to 0x01.
I am connecting two hardware to two different channels .Both the channel has to be monitored continuously and the data has to be extracted.
I am not clear in configuring the adc channel for multiple input .
Easy. You either run an interrupt handler and have the ADC convert continuously. Then every second interrupt will be the first or second input.
Or you have to specifically select the first input. Start conversion. Wait for answer. Read out answer. Start second conversion. Wait for answer. Read out answer.
What is unclear, when the manual says that if software mode, you can only start conversion of one (1) input? And in hardware scan mode, you can set up any combination of up to 8 inputs and it will continuously scan the selected inputs?