TN06004 LPC2000 Adc
TN06004 LPC2000 Adc
Introduction
This technical note gives two software examples showing the use the 10-bit A/D converter of the Philips
Semiconductors LPC2000 microcontroller family. The examples are written for the LPC2129 (and tested on
an MCB2100 board), but are valid for all earlier Philips ARM devices (without individual result registers).
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
int main(void)
{
UART0_Init(); // Initialize UART0
while (1)
{
Print12B(ADC_Read(1)); // convert and print channel AIN0
PrintString(" ");
Print12B(ADC_Read(2)); // convert and print channel AIN1
PrintString(" ");
Print12B(ADC_Read(4)); // convert and print channel AIN2
PrintString(" ");
Print12B(ADC_Read(8)); // convert and print channel AIN3
PrintString("\r");
}
}
Philips Semiconductors TN06004
LPC2000 ADC code example
int main(void)
{
VICVectAddr0 = (unsigned int) &ADC_Isr;
VICVectCntl0 = 0x32; // Channel0 on Source#18 ... enabled
VICIntEnable |= 0x40000; // 18th bit is the ADC
while (1)
{
Print12B(ADCresult[0]); // print result channel AIN0
PrintString(" ");
Print12B(ADCresult[1]); // print result channel AIN1
PrintString(" ");
Print12B(ADCresult[2]); // print result channel AIN2
PrintString(" ");
Print12B(ADCresult[3]); // print result channel AIN3
PrintString("\r");
}
}