HAL_UART_Transmit but nothing is sent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-02 5: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-02 6: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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-02 7:28 AM
It is a STM32F091. It works for many hours. I obtain always Result= HAL_OK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-02 7:29 AM
I will retry using the debugger.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-07 6:10 AM
Maybe the problem was about the wrong setup of the mcu clock.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-11-07 6:53 AM
Did you check oscillator on your Tx pin can you see any messages there ?
