Skip to main content
VijayRakeshM
Associate III
Mar 29, 2019 10:29 AM UTC
Solved

Unable to receive UART data randomly

Hi,

I'm using STM32L0 series and working on UART to communicate with other module and I had chosen the polling method because i know the device max response time and exact data what i'm going to receive. I was running my application for testing and it worked fine for 24 hours and then after and MCU not able to receive data even the module is responding i don't understand this scenario, can anyone please suggest what could be the problem. Thanks in advance.

Regards,

Vijay Rakesh

HAL_UART_Transmit(&huart1,A_Buff,7,200);
HAL_UART_Receive(&huart1,Rx_Buf,4,5000); // Timeout value is 5 seconds to receive data

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Apr 1, 2019 3:10 PM UTC

In my work I generally use a pair of FIFO buffers, and manage the reception/transmission from those directly in the IRQ Handler. The data is inserted and removed from the FIFO in a worker or foreground task so the interrupt is not loaded with processing overhead.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

8 replies

S.Ma
Principal
Mar 29, 2019 12:23 PM UTC

It is looking for trouble to process rx in polling. At least get a cyclic dma buffer in reception si there won t be any timeout issue.

VijayRakeshM
Associate III
Mar 29, 2019 12:40 PM UTC

Hi @S.Ma​ 

Thanks for the reply, I don't have any idea on implementing DMA could please refer any document so that i can implement your suggestion and just now I have implemented UART interrupt method could this method can solve the above issue?

Regards,

Vijay Rakesh.

Tesla DeLorean
Guru
Mar 29, 2019 3:01 PM UTC

They way you've implemented this with blocking functions is not conducive to concurrent transmit/receive. The HAL libraries just make such a mess of this rather than implementing some clean ring buffering.

My guess would be that you are getting over/under run type errors, or noise errors that don't get cleared and result in data loss. Compounded by fixed expectations about how much data will be received.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Mar 29, 2019 12:54 PM UTC

Check on stm32 library folders, nucleo board, usart projects.