MCUXpresso SDK Documentation

usart_transfer_dma

usart_transfer_dma#

Overview#

This example shows how to use the DMA driver to implement a double buffer receive scheme from the USART The example shows the double buffer constructed using two descriptors (g_pingpong_desc). These descriptors are cycled from one to the other.

Things to note :

  • The descriptors of the ping pong transfer need to be aligned to size 16

  • The initial transfer will perform the same job as first descriptor of ping pong, so the first linkeage is to go to g_pingpong_desc[1]

  • g_pingpong_desc[1] then chains the g_pingpong_desc[0] as the next descriptor

  • The properties are set up such that g_pingpong_desc[0] (and the initial configuration uses INTA to signal back to the callback)

  • g_pingpong_desc[1] uses INTB to signal to the callback

  • The scheduled callback uses this information to know which data was last written

A note on Performance : The intent of this example is to illustrate how a double-buffer scheme can be implemented using the dma. The performance of this example will be limited to how quickly the echo printer can read-out the data from the ping pong buffer and display it. This means that the example will work well if characters are entered at a rate where the DMA callback to echo the string can keep up with the input stream. Connecting the USART RX to a continuous fast speed will cause the DMA to fall behind.

Supported Boards#

LPC845BREAKOUT
Hardware requirements
  • Micro USB cable

  • LPC845 Breakout board

  • Personal Computer

Board settings

No special settings are required.

Prepare the demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port on the board.

  2. Open a serial terminal with the following settings:

    • 9600 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output of the USART transfer using DMA driver example in the terminal window:

USART DMA transfer Example.
The USART will echo the double buffer after each 8 bytes:

LPCXpresso824MAX
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso824MAX board

  • Personal Computer

Board settings

Connect SJ9: 2-3

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port on the board

  2. Open a serial terminal with the following settings:

    • 9600 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output of the hello world demo in the terminal window:

Usart polling example.
Board will send back received characters.
Now, please input any character:

LPCXpresso845MAX
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso845MAX board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port on the board

  2. Open a serial terminal with the following settings:

    • 9600 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output of the hello world demo in the terminal window:

Usart polling example.
Board will send back received characters.
Now, please input any character:

LPCXpresso860MAX
Hardware requirements
  • Micro USB cable

  • LPCXpresso860MAX board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port on the board

  2. Open a serial terminal with the following settings:

    • 9600 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output of the hello world demo in the terminal window:

USART DMA transfer Example.
The USART will echo the double buffer after each 8 bytes: