2024-02-14 11:23 PM
Hi!
I am somewhat unclear on how to handle variable length transmissions using the STM32F4xx HAL. I have looked at other solutions, and suggestions have been made to use HAL_UARTEx_ReceiveToIdle_DMA() or the ISR equivalent.
My situation however, involves a continuous non stopping transmission from a NEOM8N GPS Module. The GPS has a default baud rate of 9600, which I have observed in my code. It uses the NMEA0183 protocol, which has a max sentence length of 83 characters.
Any suggestions on how to implement the receive function for this GPS?
Solved! Go to Solution.
2024-02-15 01:12 AM - edited 2024-02-15 01:13 AM
> The STM32 only reads the start and stop for bytes adds them to the buffer, until buffer size (max Nmea sentence length) is reached.
No this is not STM32. This is the little poor "HAL library", suitable for quick bring-up tests and reference but not for production code. STM32 hardware itself is great, it supports continuous RX with DMA or interrupts - the latter is trivial at 9600 and simpler than DMA. Just do the proper code.
2024-02-15 01:23 AM
Will do thank you for your help!
2024-02-15 04:34 PM
See this link which explains how to work with variable length data using HAL_UARTEx_ReceiveToIdle_DMA
https://github.com/karlyamashita/Nucleo-G431RB_Three_UART/wiki
2024-02-15 05:26 PM
Well the interrupt into a ring buffer works, it is preferable to do the parsing outside of the handler, as doing a lot of math and processing can be time consuming.
One could use a circular DMA buffer, acting like the HW FIFO from earlier systems, which gets swept periodically, I do that rather than this idle stuff.The parser drops through quickly if there's insufficient data to close out a NMEA Sentence.
UBX Packets have length information in the header.