Overview
The FlexIO UART example application demonstrates the FlexIO-simulated UART driver working with different methods. The FlexIO UART example shows the transmit/receive between the FlexIO-simulated UART and the LPUART1 using interrupts and DMA:
- flexio_uart_example using interrupts
- flexio_uart_dma_example using DMA
Supported Platforms
These Freescale Freedom development platforms and Tower System modules are supported by the FlexIO UART example.
- TWR-KL43Z48M
- FRDM-KL43Z
- FRDM-KL27Z
System Requirement
Hardware requirements
- J-Link ARM
- PE Micro Multi-link universal
- Mini/micro USB cable
- USB A to micro AB cable
- Personal Computer
Toolchain requirements
- IAR embedded Workbench version 7.30.4
- ARM GCC 4.8.3 2014q3
- Keil MDK 5.13
- Kinetis Design Studio IDE v.2.5
- Atollic TrueSTUDIO for ARM win32 v5.2.1
Software requirements
- The project files are in: <SDK_Install>/examples/<board>/driver_examples/flexio/uart/<use_case>/<toolchain>.
- Library dependencies: ksdk_platform_lib
Getting Started
Hardware settings
This example requires connecting the FLEXIO pins with the LPUART1 pins. Connect the FlexIO pins to the LPUART1 pins. Note that the default uses the FlexIO pin2 and pin4:
FlexIO Pins | Connects To | LPUART1 Pins |
FlexIO Pin2 | -> | LPUART1 Rx |
FlexIO Pin4 | -> | LPUART1 Tx |
Make these connections between the FlexIO pins and LPUART pins by using external wires:
TWR-KL43Z48
FlexIO Pins | Connects To | LPUART Pins |
Pin Name | Board Location | | Pin Name | Board Location |
PTD0/FLEXIO_PIN2 | Primary Elevator B45 | -> | LPUART1 Rx | TWR-KL43Z48M J15-14 |
PTD0/FLEXIO_PIN4 | Primary Elevator B59 | -> | LPUART1 Tx | Primary Elevator B47 |
FRDM-KL43Z
Because the LPUART1_RX is not pinned out on the FRDM-KL43Z, the example only demonstrates the FlexIO UART Rx:
FlexIO Pins | Connects To | LPUART Pins |
Pin Name | Board Location | | Pin Name | Board Location |
PTD4/FLEXIO_PIN4 | J2-6 | -> | LPUART1 Tx | J1-7 |
FRDM-KL27Z
FlexIO Pins | Connects To | LPUART Pins |
Pin Name | Board Location | | Pin Name | Board Location |
PTD0/FLEXIO_PIN2 | J1-5 | -> | LPUART1 Rx | J3-3 |
PTD4/FLEXIO_PIN4 | J1-9 | -> | LPUART1 Tx | J3-1 |
Prepare the example
- Connect a USB cable between the PC host and the OpenSDA USB port on the board.
- Insert TWR board into TWR-ELEV.
- Open a serial terminal with these settings:
- 115200 baud rate
- 8 data bits
- No parity
- One stop bit
- No flow control
- Download the program to the target board.
- Either press the reset button on your board or launch the debugger in your IDE to begin running the example.
Run the example
FLEXIO_UART_DMA interrupt method
These instructions are displayed/shown on the terminal window:
++++++++++++++++ FLEXIO UART Send/Receive Example Start +++++++++++++++++
1. FlexIO simulated UART send a
buffer
2. LPUART1 receives data from FlexIO simulated UART.
5. FlexIO simulated UART receives data from LPUART1.
============================================================
Press any key to start transfer:
Type a character from the keyboard and the FlexIO simulated UART sends a buffer to the LPUART1, compares the receive buffer in the LPUART1 side with the txBuff and checks whether the result is successful. Then, the LPUART1 sends a buffer to the FlexIO simulated UART, compares the received buffer in the FlexIO-simulated UART side with the txBuff and checks whether the result is successful.
FlexIO simulated UART receive from FlexIO LPUART1 successfully
FlexIO simulated UART receive from FlexIO LPUART1 successfully
FlexIO simulated UART receive from FlexIO LPUART1 successfully
FlexIO simulated UART receive from FlexIO LPUART1 successfully
...
For other boards:
Transfer from FlexIO simulated UART to LPUART1 successfully
FlexIO simulated UART receive from FlexIO LPUART1 successfully
Transfer from FlexIO simulated UART to LPUART1 successfully
FlexIO simulated UART receive from FlexIO LPUART1 successfully
Transfer from FlexIO simulated UART to LPUART1 successfully
FlexIO simulated UART receive from FlexIO LPUART1 successfully
Transfer from FlexIO simulated UART to LPUART1 successfully
FlexIO simulated UART receive from FlexIO LPUART1 successfully
Transfer from FlexIO simulated UART to LPUART1 successfully
FlexIO simulated UART receive from FlexIO LPUART1 successfully
...
FLEXIO_UART_DMA interrupt method
These instructions are displayed/shown on the terminal window:
++++++++++++++++ FLEXIO UART Send/Receive DMA Example Start +++++++++++++++++
1. FlexIO simulated UART send a
buffer using DMA
2. LPUART1 receives data from FlexIO simulated UART.
5. FlexIO simulated UART receives data from LPUART1 using DMA.
============================================================
Press any key to start transfer:
Type a character from the keyboard and the FlexIO-simulated UART sends a buffer to the LPUART1, compares the received buffer in the LPUART1 side with the txBuff, checks whether the result is successful. Then, the LPUART1 sends a buffer to the FlexIO-simulated UART, compares the received buffer in the FlexIO-simulated UART side with the txBuff and checks whether the result is successful.
FlexIO simulated UART receive from FlexIO LPUART1 using DMA successfully
FlexIO simulated UART receive from FlexIO LPUART1 using DMA successfully
FlexIO simulated UART receive from FlexIO LPUART1 using DMA successfully
FlexIO simulated UART receive from FlexIO LPUART1 using DMA successfully
...
For other boards:
Transfer from FlexIO simulated UART to LPUART1 using DMA successfully
FlexIO simulated UART receive from FlexIO LPUART1 using DMA successfully
Transfer from FlexIO simulated UART to LPUART1 using DMA successfully
FlexIO simulated UART receive from FlexIO LPUART1 using DMA successfully
Transfer from FlexIO simulated UART to LPUART1 using DMA successfully
FlexIO simulated UART receive from FlexIO LPUART1 using DMA successfully
Transfer from FlexIO simulated UART to LPUART1 using DMA successfully
FlexIO simulated UART receive from FlexIO LPUART1 using DMA successfully
...