Skip to main content
Graduate II
March 6, 2024
Question

Ring buffer implementation does not work as intended

  • March 6, 2024
  • 2 replies
  • 2819 views

Hi all,

I am trying to implement ring buffer for my board that is STM32F407VG-DISC1. I have found out a tutorial and followed each and every step. However, when I transmitted message via serial console tool (hercules), I dont receive any data in Rx Buffer. 

In the first snapshot attached, I can observe that Uart_sendstring function is working as I can see on the console (Hercules) "send string works". 

However, when I send 11111 it is not received, therefore rxbuffer is empty as can be seen in the second snapshot and also uart_write function is not run, as "if(IsDataAvailable())" returns "0".

 

Could you please help me with this ?

You can see the repo here.

    This topic has been closed for replies.

    2 replies

    Super User
    March 6, 2024

    Here is a good ring buffer code that works.

    https://github.com/MaJerle/lwrb

     

    Graduate II
    March 6, 2024

    Check this git project https://github.com/karlyamashita/Nucleo-G431RB_Three_UART/wiki

    It uses HAL_UARTEx_ReceiveToIdle_DMA so it'll interrupt on packets of data/messages instead of interrupting on each byte. Less overhead if you can use the DMA to do all the work while the STM32 if free to do other tasks. It uses a data structure so you can easily define multiple UART ports.

     

    The problem with the repo link you provided is that is was designed for 1 UART/buffer so would have to be modified if you wanted to add more UART ports. 

    Graduate II
    April 9, 2025

    Hi thanka for sharing

    can the code you gave work with FreeRtos?

     

    And if yes, it would be great if you can say what main changes need to be done.