Here goes the second post on " How to program the onboard adc in LPC2129"
As said earlier LPC2129 has 4 onboard 10-bit ADC. Also these ADC's are internally multiplexed. So here i give out a snippet of how you could access the ADC's on LPC21xx.
At the time of writing this post,i dnt believe that any further explanation is needed . In case you need please refer to the end of line comment or feel free to comment ont he post.
#include "LPC21xx.H" // LPC21xx definitions
static unsigned short ADC_Config(unsigned char channel)
{
unsigned int i;
ADCR = 0x00200300 | ch; // Init ADC (Pclk = 12MHz) and select channel
ADCR |= 0x01000000; // Start A/D Conversion
do
{
i = ADDR; // Read A/D Data Register
} while ((i & 0x80000000) == 0); // Wait for end of A/D Conversion
return (i >> 6) & 0x03FF; // bit 6:15 is 10 bit AD value
}
int main(void)
{
while (1)
{
ADC_Config(2); // Access adc corresponding to the port
ADC_Config(4);
}
}
1 comment:
i need to increase conversion rate and get the data samples per second will be more and i need to use single channel only please help to changes in the code to make
Post a Comment