2019-03-29 3:29 AM
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
Solved! Go to Solution.
2019-04-01 8:10 AM
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.
2019-03-29 5:23 AM
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.
2019-03-29 5:40 AM
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.
2019-03-29 5:54 AM
Check on stm32 library folders, nucleo board, usart projects.
2019-03-29 8:01 AM
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.
2019-03-31 10:17 PM
Hi @Community member ,
Thanks for the reply, what can be the best solution for implementing concurrent transmit/receive.
Regards,
Vijay Rakesh
2019-04-01 8:10 AM
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.
2019-04-01 10:57 PM
I was actually trying to do the same after facing the issue but i couldn't find the call back for each UART data I receive and I can only find HAL_UART_RxCpltCallback() where I need to mention how much data I'm about to receive.
2019-04-01 11:53 PM
HAL functions are built for expected length messages. Otherwise, use length of "1".
Otherwise use LL (low layer) especially for USART peripheral as it's pretty manageable.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.