Amruta (talk) 13:28, 17 March 2015 (IST)


Basics

LPC1768 has 12 bit ADC which is multiplexed among 8 input pins. It's measurement range is typically 3V which means that ADC resolution is approximately 0.7 mV.

Registers

Here we will discuss commonly used ADC registers.

ADCR ( ADC Control Register )
ADCR
31:28 27 26:24 23:22 21 20:17 16 15:8 7:0
Reserved EDGE START Reserved PDN Reserved BURST CLCKDIV SEL
ADGDR ( ADC Global Data Register )
ADCR
31 27 26:24 23:16 15:4 3:0
Done EDGE Channel Reserved RESULT Reserved

Schematic

Code

  1. /*-----------------------------------------------------------------------------
  2. note : Refer adc.h to enable ADC channels.
  3. ------------------------------------------------------------------------------*/
  4. #include "lpc17xx.h" //device specific heaader file
  5. #include "uart.h" //Explore Embedded UART library which conatins the lcd routines
  6. #include "adc.h" //Explore Embedded ADC library which conatins the adc routines
  7.  
  8. /* start the main program */
  9. int main()
  10. {
  11. uint16_t adc_result;
  12.  
  13. /* Setup and initialize the microcontroller system */
  14. SystemInit();
  15.  
  16. /* Initialize the UART before displaying any thing on the lcd */
  17. UART_Init(UART0,9600);
  18.  
  19. /* Initialize the adc before starting the conversion */
  20. ADC_Init();
  21.  
  22. /* Display "ADC Channel zero" on first line*/
  23. UART_Printf("ADC Channel zero");
  24.  
  25. /* Display the adc channel zero value continously */
  26. while(1)
  27. {
  28. /*Get the adc value of channel five */
  29. adc_result= ADC_GetAdcValue(5);
  30.  
  31. /*Display the adc value on UART*/
  32. UART_Printf("\n %u",adc_result);
  33. }
  34. }