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

Bit 7:0 – SEL : Channel Select These bits select which of the AD0.7:0 pins is (are) to be sampled and converted. There is one bit per channel e. g. bit o for AD0, bit 7 AD7. Write one to enable respective channel. All zeroes is equivalent to 0x01. Bit 15:8 – CLCKDIV : Clock Divisor The APB clock (PCLK_ADC0) is divided by (this value plus one) to produce the clock for the A/D converter, which should be less than or equal to 13 MHz. Bit 16 – BURST Repeated conversions can be terminated by clearing this bit. Bit 21 – PDN : Power Down Mode Setting this bit brings ADC out of power down mode and makes it operational. Bit 24:26 – START When the BURST bit is 0, these bits control whether and when an A/D conversion is started:

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. }

CoIDE with ARMGCC for ARM Development

Amruta (talk) 10:30, 10 March 2015 (IST) Intro Welcome to the world of ARM Microcontrollers. In this tutorial, we will look at setting up free and open-source tools for ARM Development...

Setting up Keil for ARM

Amruta (talk) 19:22, 11 March 2015 (IST) Sample Project for LPC1768 Let’s start with a simple LED blinking program. Launch the Keil application and follow the steps below...

ARM Timer Programming

Amruta (talk) 13:24, 17 March 2015 (IST) Basics Schematic Code /** * RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW...

ARM Interrupt Programming

Amruta (talk) 13:25, 17 March 2015 (IST) Basics Schematic Code /** * RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW...