LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
UART example

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_Type *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 uartPolling_menu1 [] = "Hello NXP Semiconductors \n\r"
 
static uint8_t uartPolling_menu2 [] = "UART polling mode demo \n\r"
 
static uint8_t uartPolling_menu3 [] = "\n\rUART demo terminated!"
 
static uint8_t uartPolling_menu4 []
 
static uint8_t uartPolling_menu5 [] = "\n\rPolling mode is running now! Please press \'c\' and choose another mode \n\r"
 
static uint8_t uart_interrupt_menu []
 
static uint8_t uart_interrupt_menu1 [] = "UART interrupt menu 1 \n\r"
 
static uint8_t uart_interrupt_menu2 [] = "UART interrupt menu 2 \n\r"
 
static uint8_t uart_interrupt_menu3 [] = "UART interrupt menu 3 \n\r"
 
static uint8_t uart_interrupt_menu4 [] = "UART interrupt menu 4 \n\r"
 
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
 

Detailed 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 115K8N1. Change modes by selecting the option from the terminal.

No special setup is required for the demo. Just build and run.

Build procedure: LPCOpen 18xx/43xx build instructions

Supported boards and board setup:

Submit bug reports for LPCOpen code here.

Macro Definition Documentation

#define DMA_TIMEOUT   0xA000000

Definition at line 120 of file uart.c.

#define LPC_UART   LPC_USART0

Definition at line 76 of file uart.c.

#define UARTx_IRQHandler   UART0_IRQHandler

Definition at line 78 of file uart.c.

#define UARTx_IRQn   USART0_IRQn

Definition at line 77 of file uart.c.

Function Documentation

void App_DMA_DeInit ( void  )

Definition at line 151 of file uart.c.

void App_DMA_Init ( void  )

Definition at line 140 of file uart.c.

void App_DMA_Test ( void  )

Definition at line 159 of file uart.c.

void App_Interrupt_DeInit ( void  )

Definition at line 234 of file uart.c.

void App_Interrupt_Init ( void  )

Definition at line 214 of file uart.c.

void App_Interrupt_Test ( void  )

Definition at line 245 of file uart.c.

void DMA_IRQHandler ( void  )

GPDMA interrupt handler sub-routine.

Returns
Nothing

Definition at line 294 of file uart.c.

int main ( void  )

Main UART program body.

Returns
Always returns -1

Definition at line 324 of file uart.c.

void Print_Menu_Interrupt ( LPC_USART_Type UARTx)

Definition at line 198 of file uart.c.

void Print_Menu_Polling ( void  )

Definition at line 279 of file uart.c.

void UARTx_IRQHandler ( void  )

UART interrupt handler sub-routine.

Returns
Nothing

Definition at line 315 of file uart.c.

Variable Documentation

volatile uint32_t channelTC
static

Definition at line 127 of file uart.c.

volatile uint32_t channelTCErr
static

Definition at line 128 of file uart.c.

uint8_t dmaChannelNumRx
static

Definition at line 123 of file uart.c.

uint8_t dmaChannelNumTx
static

Definition at line 123 of file uart.c.

FunctionalState isDMATx = ENABLE
static

Definition at line 129 of file uart.c.

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

Definition at line 112 of file uart.c.

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

Definition at line 114 of file uart.c.

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

Definition at line 115 of file uart.c.

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

Definition at line 116 of file uart.c.

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

Definition at line 117 of file uart.c.

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

Definition at line 124 of file uart.c.

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

Definition at line 102 of file uart.c.

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

Definition at line 103 of file uart.c.

uint8_t uartPolling_menu3[] = "\n\rUART demo terminated!"
static

Definition at line 104 of file uart.c.

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

Definition at line 105 of file uart.c.

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

Definition at line 109 of file uart.c.