LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
LPC17xx/40xx ADC example

Detailed Description

Example description
This example describes how to use ADC conversion in POLLING mode, INTERRUPT mode and DMA mode.

For LPC1788 and LPC4088, the ADC conversion rate is 400KHz. A/D converter requires 31 clocks for a fully accurate conversion. Therefore, ADC clock = 400KHz * (number of clocks for 1 measure = 31 clocks). Note that maximum ADC clock input is 12.4MHz.

For LPC1769, the maximum ADC clock input is 13MHz. 65 ADC converter's clocks are required for a full conversion. The conversion rate is 200KHz.

The ADC value can be read in POLLING mode, INTERRUPT mode or DMA mode. Converted ADC values displayed periodically via the UART. Turn potentiometer to change ADC signal input.

Setting up the demo requires connecting a UART cable between the board and a host PC. The terminal program on the host PC should be setup for 115K8N1. Press the appropriate key via the menu to change the ADC conversion mode.

Special connection requirements

Build procedures:
LPC17xx/40xx example quickstart for Keil uVision4
LPC17xx/40xx example quickstart for IAR EWARM
LPC17xx/40xx example quickstart for Code Red Xpresso

Supported boards and board setup:
Embedded Artists' LPC1788 Developer's Kit
Embedded Artists' LPC4088 Developer's Kit
NXP Xpresso LPC1769 board

Submitting LPCOpen issues:
Community support for LPCOpen

Functions

static void App_print_ADC_value (uint16_t data)
 
static void App_DMA_Test (void)
 
static void App_Interrupt_Test (void)
 
static void App_Polling_Test (void)
 
void ADC_IRQHandler (void)
 ADC0 interrupt handler sub-routine.
 
void DMA_IRQHandler (void)
 DMA interrupt handler sub-routine.
 
int main (void)
 Main routine for ADC example.
 

Variables

static char WelcomeMenu []
 
static char SelectMenu []
 
static ADC_Clock_Setup_T ADCSetup
 
static volatile uint8_t Burst_Mode_Flag = 0
 
static volatile uint8_t Interrupt_Continue_Flag
 
static volatile uint8_t ADC_Interrupt_Done_Flag
 
static volatile uint8_t channelTC
 
static volatile uint8_t dmaChannelNum
 
uint32_t DMAbuffer
 

Function Documentation

void ADC_IRQHandler ( void  )

ADC0 interrupt handler sub-routine.

Returns
Nothing

Definition at line 244 of file adc.c.

static void App_DMA_Test ( void  )
static

Definition at line 127 of file adc.c.

static void App_Interrupt_Test ( void  )
static

Definition at line 177 of file adc.c.

static void App_Polling_Test ( void  )
static

Definition at line 204 of file adc.c.

static void App_print_ADC_value ( uint16_t  data)
static

Definition at line 117 of file adc.c.

void DMA_IRQHandler ( void  )

DMA interrupt handler sub-routine.

Returns
Nothing

Definition at line 264 of file adc.c.

int main ( void  )

Main routine for ADC example.

Main program body.

Returns
Nothing

Definition at line 278 of file adc.c.

Variable Documentation

volatile uint8_t ADC_Interrupt_Done_Flag
static

Definition at line 106 of file adc.c.

ADC_Clock_Setup_T ADCSetup
static

Definition at line 104 of file adc.c.

volatile uint8_t Burst_Mode_Flag = 0
static

Definition at line 105 of file adc.c.

volatile uint8_t channelTC
static

Definition at line 106 of file adc.c.

uint32_t DMAbuffer

Definition at line 107 of file adc.c.

volatile uint8_t dmaChannelNum
static

Definition at line 106 of file adc.c.

volatile uint8_t Interrupt_Continue_Flag
static

Definition at line 105 of file adc.c.

char SelectMenu[]
static
Initial value:
= "\r\nPress number 1-3 to choose ADC running mode:\r\n"
"\t1: Polling Mode \r\n"
"\t2: Interrupt Mode \r\n"
"\t3: DMA Mode \r\n"

Definition at line 99 of file adc.c.

char WelcomeMenu[]
static
Initial value:
= "\r\nHello NXP Semiconductors \r\n"
"ADC DEMO \r\n"
"Sample rate : 400kHz \r\n"
"Press \'c\' to continue or \'x\' to quit\r\n"
"Press \'o\' or \'p\' to set Sample rate\r\n"
"Press \'b\' to ENABLE or DISABLE Burst Mode\r\n"

Definition at line 89 of file adc.c.