cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4S9 UART Receive Problem.

SEfte.1
Associate II

0693W00000SuOELQA3.pngUart Configuration0693W00000SuOEGQA3.pngUart Receive Code

Hello,

I am working on a project with STM32L4S9 mcu and I am trying to receive data via uart from a GPS module (ublox CAM m8) which is continuously sending data. The problem is that when I am trying to debug with breakpoint exactly before the HAL_UART_receive the mcu receives the data correctly but when the program is running without breakpoints , it loses/misses bytes and data are not coming in the correct order. I made a clean project only with UART and GPS and everything is ok. I receive data correctly anything missing and data are in the correct order. Any Ideas what is happening? In the pictures above you can see the code i used for UART receiving and the UART configuration.

Thanks In Advance.

5 REPLIES 5

You're asking it to receive 100 bytes, not 1

How is gps_buffer defined?

You losing data is not a configuration issue.

HAL_UART_Receive() is a blocking function, how do you determine data missing/lost? If you use HAL_UART_Transmit() on 100 bytes you're apt to miss 99+ on the receive side.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
SEfte.1
Associate II

Hello and thank you for your help,

Buffer is defined as char with size 500. I tried to receive 1 byte per time and with this way I receive only the first byte and then I don't receive nothing.

https://portal.u-blox.com/s/question/0D52p0000CkwJspCQE/cam-m8c-uart-receive-problem

Ok, but not clear how you're making any of these determinations, or where the data is going out of this loop. Break pointing isn't helpful as the data is continuous and keeps flowing while you ponder in the debugger.

Does it output the error message? You don't say.

Screen shots of odd code blocks aren't helping with the big-picture issues. Paste some code that's at least functionally complete. Use the code tool, see the </> icon below the message entry window.

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

Perhaps you have a secondary UART you can do a simple byte-wise forwarding too?

Or build some simple line parsing code to collect NMEA sentences for decode or dispatch.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
SEfte.1
Associate II

Hello again,

For that you asked. UART doesn't output any error messages but it loses bytes and the message is

stored to my buffer with wrong order. The reception finish with out errors.

UPDATE

In my clean project I noticed the I receive data correctly when only UART is working. But when I activate RTOS and RTC I have the same problem. Any Ideas?