Skip to main content
SNguy.3
Associate II
September 12, 2022
Solved

STM32L432 use both usart1 and usart2 receive missing data

Hi,

I write the firmware using STM32L432 (NucleoL432-KC) used usart1 and usart2 with DMA RX/TX and received idle line.

The usart1 and usart2 using pin of the same port (PORT-A)

The problem is lost receive data if I receive data on both port at the same time. The project generates using CubeMX (attached file)

The code to start receiving DMA with idle line detect

void mb_port_start_recv(void* uart, uint8_t* buf, uint16_t buf_size)
{
	UART_HandleTypeDef* huart = (UART_HandleTypeDef*)uart;
	HAL_UARTEx_ReceiveToIdle_DMA(huart, buf, buf_size);
}

The is no problem if run each usart at time.

Anyone know what is problem?

Thank you!

This topic has been closed for replies.
SNguy.3
SNguy.3Best answer
Associate II
September 17, 2022

Thank @Tesla DeLorean for your supported.

The problem is solved.

I have use the same the tx buffer for both uart.

5 replies

Tesla DeLorean
Guru
September 12, 2022

>>Anyone know what is problem?

Management of multiple concurrent streams and buffers.

Solving parallel problems with serialized coding methods/styles.

Not being ready listening when data arrives.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
SNguy.3
SNguy.3Author
Associate II
September 12, 2022

HI @Community member​ 

Thank for your response.

All the data receive as concurrent by using DMA then handle idle line detect interrupt and copy this data to buffer. On main loop get buffer out and process it.

The process very fast has no problem with buffer overflow. My problem is data is not really received by DMA

Tesla DeLorean
Guru
September 12, 2022

DMA should work robustly. Buffers should be large enough, and perhaps enough of them so that new resources can be committed so the current holding buffer is not active whilst being touched by your processing code.

Would check for Noise, Framing, Overrun, Parity type conditions precluding the reception of subsequent data. These need to be cleared, but may also be indicative of data loss already occurring.

I would tend not to use the idle methods, preferring to use continuous/circular methods, and sweeping the buffer periodically, and managing inter-packet timeouts there.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
SNguy.3
SNguy.3Author
Associate II
September 13, 2022

Yes, I already try using interrupt and timer but the same problem. No data lost if only one uart run. Data start lose when two uart work. Also do transfer very slow 500ms each message 8-15 byte.

Thank for your solution, I try to debug more and hope there is no hardware problem.