2018-11-02 05:27 AM
Hi. I'm using these lines of code
Result= HAL_UART_Transmit(serial, BufferSerialWrite, BufferSize, HAL_MAX_DELAY);
to send data but, after some hours, nothing exits from the uart. I have to reboot the mcu.
How can I resolve this problem?
The line of cose
HAL_UART_Init(serial);
hasn't got any effect
2018-11-02 06:07 AM
Lots to work with here..
What STM32 part?
Does it return an error? Works for hours and stops, or never works?
Check status/errors reported in USART SR, inspect in debugger.
Sure it is not another problem? Like getting stuck in Hard Fault Handler, or in interrupt context.
2018-11-02 07:28 AM
It is a STM32F091. It works for many hours. I obtain always Result= HAL_OK
2018-11-02 07:29 AM
I will retry using the debugger.
2018-11-02 11:48 AM
You do realize that HAL_MAX_DELAY will tell the function to wait more than 49 DAYS before timing out? Try setting this to a more reasonable value and see if you then get an error returned from HAL_UART_Transmit().
Look at the source for HAL_UART_Transmit(), see where it loops waiting for a flag or timeout. In fact, run with your debugger, wait till it "hangs" then break. That should show you which flag it is waiting for. The BIG question is what that flag isn't getting set/reset.
That is *IF* the problem is in the HAL_UART_Transmit() function. Otherwise it may be in a fault or interrupt handler as @Community member mentioned.
2018-11-07 06:10 AM
Maybe the problem was about the wrong setup of the mcu clock.
2018-11-07 06:53 AM
Did you check oscillator on your Tx pin can you see any messages there ?