usart_dma_double_buffer_transfer#
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 inital 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#
EVK-MIMXRT595
Hardware requirements
Micro USB cable
EVK-MIMXRT595 board
Personal Computer
Board settings
Prepare the Demo
Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J40) on the board
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Launch the debugger in your IDE to begin running the demo.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
EVK-MIMXRT685
Hardware requirements
Micro USB cable
EVK-MIMXRT685 board
Personal Computer
Board settings
Prepare the Demo
Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J5) on the board
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Launch the debugger in your IDE to begin running the demo.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
FRDM-MCXW23
Hardware requirements
Type-C USB cable
FRDM-MCXW23 Board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a USB cable between the host PC and the FRDM board J10.
Open a serial terminal with the following 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 demo.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
FRDM-RW612
Hardware requirements
Micro USB cable
FRDM-RW612 board
Personal Computer
Board settings
Prepare the Demo
Connect a micro USB cable between the PC host and the MCU-Link USB port (J10) on the board
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Launch the debugger in your IDE to begin running the demo.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
LPCXpresso51U68
Hardware requirements
Micro USB cable
LPCXpresso51U68 board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J6) on the board
Open a serial terminal with the following settings (See Appendix A in Getting started guide for description how to determine serial port number):
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the CMSIS DAP terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
LPCXpresso54628
Hardware requirements
Micro USB cable
LPCXpresso54628 board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a micro USB cable between the PC host and the LPC-Link USB port (J8) on the board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
LPCXpresso54S018
Hardware requirements
Micro USB cable
LPCXpresso54S018 board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a micro USB cable between the PC host and the LPC-Link USB port (J8) on the board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
This demo is an external flash plain load demo, ROM will copy image in external flash to SRAMX to run:
Build the demo to generate a bin file. Note: If need to generate bin file using MCUXpresso IDE, below steps need to be followed: Set in example Properties->C/C++ Build->Settings->Build steps->Post-build steps->Edit enbable arm-none-eabi-objcopy -v -O binary “&{BuildArtifactFileName}” “&{BuildArtifactFileBaseName}.bin”
This plainload example linked the vector table to 0x00000000, but program to external flash 0x10000000.
Program the bin file to external on board flash via SEGGER J-FLASH Lite(V6.22 or higher):
a. Open SEGGER J-FLASH Lite, select device LPC54S018.
b. Click the ‘Erase Chip’ to erase the extrenal flash.(if can not success, press SW4 button and reset the board, and try to erase again)
c. Select the bin data file, set the ‘.bin/Erase Start’ address to 0x10000000, then click ‘Program Device’ Note: Please use above way to program the binary file built by armgcc tool chain to external flash. For IAR, KEIL, MCUXpresso IDE, you can use the IDE tool to program the external flash.
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
LPCXpresso54S018M
Hardware requirements
Micro USB cable
LPCXpresso54S018M board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a micro USB cable between the PC host and the LPC-Link USB port (J8) on the board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
This demo is an external flash plain load demo, ROM will copy image in external flash to SRAMX to run:
Build the demo to generate a bin file. Note: If need to generate bin file using MCUXpresso IDE, below steps need to be followed: Set in example Properties->C/C++ Build->Settings->Build steps->Post-build steps->Edit enbable arm-none-eabi-objcopy -v -O binary “&{BuildArtifactFileName}” “&{BuildArtifactFileBaseName}.bin”
This plainload example linked the vector table to 0x00000000, but program to external flash 0x10000000.
Program the bin file to external on board flash via SEGGER J-FLASH Lite(V6.22 or higher):
a. Open SEGGER J-FLASH Lite, select device LPC54S018M.
b. Click the ‘Erase Chip’ to erase the extrenal flash.(if can not success, press SW4 button and reset the board, and try to erase again)
c. Select the bin data file, set the ‘.bin/Erase Start’ address to 0x10000000, then click ‘Program Device’ Note: Please use above way to program the binary file built by armgcc tool chain to external flash. For IAR, KEIL, MCUXpresso IDE, you can use the IDE tool to program the external flash.
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
LPCXpresso55S06
Hardware requirements
Micro USB cable
LPCXpresso55S06 board
Personal Computer
Board settings
Prepare the Demo
Connect a micro USB cable between the PC host and the LPC-Link USB port (J1) on the board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
LPCXpresso55S16
Hardware requirements
Micro USB cable
LPCXpresso55S16 board
Personal Computer
Board settings
The jumper setting: Default jumpers configuration does not work, you will need to add JP20 and JP21 (JP22 optional for ADC use)
Prepare the Demo
Connect a micro USB cable between the PC host and the LPC-Link USB port (J1) on the board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
LPCXpresso55S28
Hardware requirements
Micro USB cable
LPCXpresso55S28 board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Note: MCUXpresso IDE project default debug console is semihost
Connect a micro USB cable between the PC host and the LPC-Link USB port (P6) on the board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
LPCXpresso55S36
Hardware requirements
Micro USB cable
LPCXpresso55S36 board
Personal Computer
Board settings
Prepare the Demo
Connect a micro USB cable between the PC host and the LPC-Link USB port (J1) on the board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
LPCXpresso55S69
Hardware requirements
Micro USB cable
LPCXpresso55s69 board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Note: MCUXpresso IDE project default debug console is semihost
Connect a micro USB cable between the PC host and the LPC-Link USB port (P6) on the board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
MIMXRT685-AUD-EVK
Hardware requirements
Micro USB cable
MIMXRT685-AUD-EVK board
Personal Computer
Board settings
Prepare the Demo
Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J5) on the board
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Launch the debugger in your IDE to begin running the demo.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
RD-RW612-BGA
Hardware requirements
Micro USB cable
RD-RW612-BGA board
Personal Computer
Board settings
Prepare the Demo
Connect a micro USB cable between the PC host and the MCU-Link USB port (J7) on the board
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Launch the debugger in your IDE to begin running the demo.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :
CallBack A
CallBack B
MCXW23-EVK
Hardware requirements
Mini/micro USB cable
MCXW23-EVK Board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a USB cable between the host PC and the EVK board J33.
Open a serial terminal with the following 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 demo.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
USART Receive Double Buffer Example. The USART will echo the double buffer after each 8 bytes :