String DMA send/receive application [USART of STM32]

This application uses STM32 USART DMA for sending and receiving character strings in serial communication. When character strings are long or the number of transfers is large, DMA is advantageous because it does not burden the CPU.

This is a program for sending/receiving strings by DMA transfer.

When several different strings are sent and received in succession, it is more stable for the strings to be of fixed length. Also, in transmission, with a string storage buffer, transmitted characters do not overlap.

Sending and receiving a single string does not require a buffer, and the character does not have to be fixed. Both sending and receiving are processed with an interrupt after the transfer is complete.

DMA is advantageous when strings are long or the number of transfers is large.

The point

In the sample program, both receiving and sending processes are handled in the interrupt handler for simplicity, but because interrupts are generated during the interrupt processing, the program works as long as the number of consecutive transmissions is small, but it will be faulty if the number becomes large. In a practical program, the processing in the interrupt handler should be kept to the minimum, such as setting a flag, and the sending and receiving should be processed in a normal loop.

Follow me!