In this tutorial, we are going to cover about ADC programming and how to configure the ADC registers with the help of an example. For this tutorial we are taking LPC1769 as reference and with the use of CMSIS library. As the name suggests, ADC is used to convert a given analog signal to digital form. In ARM controller Successive approximation type ADC is used for conversion purpose. There are many applications for ADC like Sensor Interfacing, Voltage and current measurement, conversion of an audio input to its digital form, etc.
The ADC is configured using the following registers:
1. Power: In the PCONP register, set the PCADC bit.
Remark: On reset, the ADC is disabled. To enable the ADC, first set the PCADC bit(A/D converter (ADC) power/clock control bit), and then enable the ADC in the AD0CR(A/D Control Register) register. To disable the ADC, first clear the PDN bit, and then clear the PCADC bit.
2. Clock: In the PCLKSEL0 register, select PCLK_ADC.
3. Pins: Enable ADC0 pins through PINSEL registers. Select the pin modes for the port pins with ADC0 functions through the PINMODE registers.
4. Interrupts: Interrupts are enabled in the NVIC using the appropriate Interrupt Set Enable register. Disable the ADC interrupt in the NVIC using the appropriate Interrupt Set Enable register.