MaJerle / stm32-usart-uart-dma-rx-tx

STM32 examples for USART using DMA for efficient RX and TX transmission
MIT License
1.27k stars 319 forks source link

Some improvements under high baud rate of serial port #36

Closed Linjieqiang closed 5 months ago

Linjieqiang commented 5 months ago

Hello, @MaJerle .

My current serial port application is 5Mbps, using RTOS thread processing. I turned on the DMA HT and FT interrupts by referring to your tutorial, and the serial port interrupt line, but my maximum data per packet is 64 words. section, in this case, should I turn off the DMA HT interrupt to reduce system overhead?

MaJerle commented 5 months ago

No. To reduce the interrupt frequency, increase the buffer that is assigned to DMA.

Please read the tutorial why you need all 3 interrupt types, HT, TC and IDLE.

Linjieqiang commented 5 months ago

My current buffer is 256 bytes, so I still need to enable the DMA interrupts of HT and FT, right? Use them in conjunction with the serial port idle interrupt. Is this the best practice for serial port reception?

MaJerle commented 5 months ago

Please read the full readme article why all these interrupts are needed. You could remove TC and HT interrupts, but inly if you can prove in the application that whoever sends you the data will never send more than your buffer size, and will ensure at least for one byte of data line to be idle, for idle interrupts.

I have been running UART at 10Mbit successfully with all three interrupts. There is practically no overhead.

Linjieqiang commented 5 months ago

OK. Thanks.