2022-09-02 06:18 AM
Uart ConfigurationUart 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.
2022-09-02 06:45 AM
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.
2022-09-02 07:11 AM
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.
2022-09-02 07:32 AM
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.
2022-09-02 09:17 AM
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.
2022-09-05 02:11 AM
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?