This example describes how to use ADC conversion POLLING mode, INTERRUPT mode or DMA mode.
The ADC conversion rate is 400KHz. A full conversion requires 11 of these clocks. So ADC clock = 400KHz * (number of clocks for 1 measure = 11 clocks). Note that maximum ADC clock input is 4.5MHz.
The ADC value can be read in POLLING mode, INTERRUPT mode or DMA mode. Converted ADC values displayed periodically via the UART when Timer 1 ticks. 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.
Build procedure: LPCOpen 18xx/43xx build instructions
Supported boards and board setup:
- Hitex LPC1850EVA-A4-2 and LPC4350EVA-A4-2 boards (uses ADC0, Channel 0)
- Keil MCB1857 and MCB4357 boards (uses ADC0, Channel 0)
Submit bug reports for LPCOpen code here.
void ADC0_IRQHandler |
( |
void |
| ) |
|
ADC0 interrupt handler sub-routine.
- Returns
- Nothing
Definition at line 233 of file adc.c.
void ADC1_IRQHandler |
( |
void |
| ) |
|
ADC1 interrupt handler sub-routine.
- Returns
- Nothing
Definition at line 261 of file adc.c.
static void App_DMA_Test |
( |
void |
| ) |
|
|
static |
static void App_Interrupt_Test |
( |
void |
| ) |
|
|
static |
static void App_Polling_Test |
( |
void |
| ) |
|
|
static |
static void App_print_ADC_value |
( |
uint16_t |
data | ) |
|
|
static |
void DMA_IRQHandler |
( |
void |
| ) |
|
DMA interrupt handler sub-routine.
- Returns
- Nothing
Definition at line 289 of file adc.c.
Main routine for ADC example.
- Returns
- Nothing
Definition at line 303 of file adc.c.
volatile uint8_t ADC_Interrupt_Done_Flag |
|
static |
Definition at line 94 of file adc.c.
Definition at line 92 of file adc.c.
volatile uint8_t Burst_Mode_Flag = 0 |
|
static |
Definition at line 93 of file adc.c.
volatile uint8_t channelTC |
|
static |
Definition at line 94 of file adc.c.
Definition at line 95 of file adc.c.
volatile uint8_t dmaChannelNum |
|
static |
Definition at line 94 of file adc.c.
volatile uint8_t Interrupt_Continue_Flag |
|
static |
Definition at line 93 of file adc.c.
Definition at line 91 of file adc.c.
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 87 of file adc.c.
Initial value:= "\r\nHello NXP Semiconductors \r\n"
"ADC DEMO \r\n"
"Sample rate : 400kHz \r\n"
"Bit accuracy : 10 bits \r\n"
"Press \'c\' to continue or \'x\' to quit\r\n"
"Press \'o\' or \'p\' to set Sample rate "
"(valid only when Burst mode is enabled)\r\n"
"Press \'k\' or \'l\' to set Bit accuracy\r\n"
"Press \'b\' to ENABLE or DISABLE Burst Mode\r\n"
Definition at line 78 of file adc.c.