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

Detailed Description

Example description
The UART example shows how to use the UART in polling, interrupt, and DMA modes.

To use the example, connect a serial cable to the board's RS232/UART port and start a terminal program to monitor the port. The terminal program on the host PC should be setup for Baudrate-8-N-1 (Baudrate is optional).
After a reset condition, press 'a' or 'A' to start Auto-baudrate mode. Once Auto baud rate mode completed, welcome menu is printed on terminal. Change modes by selecting the option from the terminal.

Special connection requirements
There are no special connection requirements for this example.

Build procedures:
LPC18xx/43xx example quickstart for Keil uVision4
LPC18xx/43xx example quickstart for IAR EWARM
LPC18xx/43xx example quickstart for Code Red Xpresso

Supported boards and board setup:
Hitex 1850 evaluation boards
Hitex 4350 evaluation boards
Keil 1857 evaluation boards
Keil 4357 evaluation boards

Submitting LPCOpen issues:
Community support for LPCOpen

Macros

#define LPC_UART   LPC_USART0
 
#define UARTx_IRQn   USART0_IRQn
 
#define UARTx_IRQHandler   UART0_IRQHandler
 
#define DMA_TIMEOUT   0xA000000
 

Functions

void App_DMA_Init (void)
 
void App_DMA_DeInit (void)
 
void App_DMA_Test (void)
 
void Print_Menu_Interrupt (LPC_USART_T *UARTx)
 
void App_Interrupt_Init (void)
 
void App_Interrupt_DeInit (void)
 
void App_Interrupt_Test (void)
 
void Print_Menu_Polling (void)
 
void DMA_IRQHandler (void)
 GPDMA interrupt handler sub-routine.
 
void UARTx_IRQHandler (void)
 UART interrupt handler sub-routine.
 
int main (void)
 Main UART program body.
 

Variables

static uint8_t uartABComplete [] = "UART Auto-Baudrate synchronized! \r\n"
 
static uint8_t uartPolling_menu1 [] = "Hello NXP Semiconductors \r\n"
 
static uint8_t uartPolling_menu2 [] = "UART polling mode demo \r\n"
 
static uint8_t uartPolling_menu3 [] = "\r\nUART demo terminated!"
 
static uint8_t uartPolling_menu4 []
 
static uint8_t uartPolling_menu5 [] = "\r\nPolling mode is running now! Please press \'c\' and choose another mode \r\n"
 
static uint8_t uart_interrupt_menu []
 
static uint8_t uart_interrupt_menu1 [] = "UART interrupt menu 1 \r\n"
 
static uint8_t uart_interrupt_menu2 [] = "UART interrupt menu 2 \r\n"
 
static uint8_t uart_interrupt_menu3 [] = "UART interrupt menu 3 \r\n"
 
static uint8_t uart_interrupt_menu4 [] = "UART interrupt menu 4 \r\n"
 
static uint8_t dmaChannelNumTx
 
static uint8_t dmaChannelNumRx
 
static uint8_t uartDMA_menu []
 
static volatile uint32_t channelTC
 
static volatile uint32_t channelTCErr
 
static FunctionalState isDMATx = ENABLE
 

Macro Definition Documentation

#define DMA_TIMEOUT   0xA000000

Definition at line 131 of file uart.c.

#define LPC_UART   LPC_USART0

Definition at line 85 of file uart.c.

#define UARTx_IRQHandler   UART0_IRQHandler

Definition at line 87 of file uart.c.

#define UARTx_IRQn   USART0_IRQn

Definition at line 86 of file uart.c.

Function Documentation

void App_DMA_DeInit ( void  )

Definition at line 162 of file uart.c.

void App_DMA_Init ( void  )

Definition at line 151 of file uart.c.

void App_DMA_Test ( void  )

Definition at line 170 of file uart.c.

void App_Interrupt_DeInit ( void  )

Definition at line 245 of file uart.c.

void App_Interrupt_Init ( void  )

Definition at line 225 of file uart.c.

void App_Interrupt_Test ( void  )

Definition at line 256 of file uart.c.

void DMA_IRQHandler ( void  )

GPDMA interrupt handler sub-routine.

Returns
Nothing

Definition at line 305 of file uart.c.

int main ( void  )

Main UART program body.

Main program body.

Returns
Always returns -1

Definition at line 335 of file uart.c.

void Print_Menu_Interrupt ( LPC_USART_T UARTx)

Definition at line 209 of file uart.c.

void Print_Menu_Polling ( void  )

Definition at line 290 of file uart.c.

void UARTx_IRQHandler ( void  )

UART interrupt handler sub-routine.

Returns
Nothing

Definition at line 326 of file uart.c.

Variable Documentation

volatile uint32_t channelTC
static

Definition at line 138 of file uart.c.

volatile uint32_t channelTCErr
static

Definition at line 139 of file uart.c.

uint8_t dmaChannelNumRx
static

Definition at line 134 of file uart.c.

uint8_t dmaChannelNumTx
static

Definition at line 134 of file uart.c.

FunctionalState isDMATx = ENABLE
static

Definition at line 140 of file uart.c.

uint8_t uart_interrupt_menu[]
static
Initial value:
=
"UART Interrupt mode demo ! \r\nPress '1' to '4' to display 4 menus \r\nPress 'x'to exit UART interrupt mode \r\n"

Definition at line 123 of file uart.c.

uint8_t uart_interrupt_menu1[] = "UART interrupt menu 1 \r\n"
static

Definition at line 125 of file uart.c.

uint8_t uart_interrupt_menu2[] = "UART interrupt menu 2 \r\n"
static

Definition at line 126 of file uart.c.

uint8_t uart_interrupt_menu3[] = "UART interrupt menu 3 \r\n"
static

Definition at line 127 of file uart.c.

uint8_t uart_interrupt_menu4[] = "UART interrupt menu 4 \r\n"
static

Definition at line 128 of file uart.c.

uint8_t uartABComplete[] = "UART Auto-Baudrate synchronized! \r\n"
static

Definition at line 110 of file uart.c.

uint8_t uartDMA_menu[]
static
Initial value:
= "Hello NXP Semiconductors (DMA mode)\r\n"
"UART DMA mode demo ! Please type 'hello NXP' to return\r\n"

Definition at line 135 of file uart.c.

uint8_t uartPolling_menu1[] = "Hello NXP Semiconductors \r\n"
static

Definition at line 113 of file uart.c.

uint8_t uartPolling_menu2[] = "UART polling mode demo \r\n"
static

Definition at line 114 of file uart.c.

uint8_t uartPolling_menu3[] = "\r\nUART demo terminated!"
static

Definition at line 115 of file uart.c.

uint8_t uartPolling_menu4[]
static
Initial value:
= "\r\nPress number 1-3 to choose UART running mode:\r\n"
"\t 1: Polling Mode \r\n"
"\t 2: Interrupt Mode \r\n"
"\t 3: DMA Mode \r\n"

Definition at line 116 of file uart.c.

uint8_t uartPolling_menu5[] = "\r\nPolling mode is running now! Please press \'c\' and choose another mode \r\n"
static

Definition at line 120 of file uart.c.