cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 + UART + DMA + IDLE detection + High Rates + Variable Length Messages = CHAOS!

Not applicable

Hi!

I have an INS that sends the following frames:

  • Frame 1 of 60 bytes every 40 ms
  • Frame 2 of 70 bytes every 20 ms
  • Frame 3 of 32 bytes every 1s
  • Frame 4 (unwanted, but impossible to deactivate) of almost 500 bytes every 2s.

I am implementing receive with Normal DMA, 115200 baudrate and IDLE detection, but I have the following problems:

1) The frames I do want are smaller than 100 bytes, but if I declare the receive buffer that size, the reception stops.

2) For that reason I have declared the buffer with a size of 500.

3) As the buffer length is 500, when the callback (TC, I ignore HT) is executed, I observe the content and there are mixed frames. I would expect that whenever IDLE is detected it will hit the callback and write to buffer position 0, but I don't know what's going on.

4) I lose frame 3, which is the smallest and least frequent.

Any suggestion?

Thanks a lot!

4 REPLIES 4
Bob S
Principal

Are you providing a HAR_UARTEx_RxEventCallback() function? That function is what gets called when an IDLE event is detected. If you instead only look for the DMA HT and TC callbacks, that ignores idle breaks.

Not applicable

Yes, that is my callback function. And inside it I make a copy of the buffer because the reception happens very fast.

Generally the point of have the HT interrupt is to allow for you to empty the inactive half of a ping-pong buffer.

I'm not sure 115200 would overwhelming for a interrupt based solution, but one could certainly construct a circular DMA buffer, and attend to it periodical. Not sure I'd be using the HAL for any of that, as it has trouble keeping out of it's own way.

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

I am precisely using HAL :(

Okay, I'll try with circular buffer for DMA. Thanks