Skip to content

ports/stm32: Enable FIFO for H7 controller. #16358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025

Conversation

ennyKey
Copy link

@ennyKey ennyKey commented Dec 4, 2024

On my board I sometimes have the problem that single bytes get lost during UART communication at 115200 baud. I use the UART.read() method and see that sometimes single bytes are missing in the middle of the data.
The reason is that sometimes the receive interrupt of the UART is not called fast enough before the next byte is received.
Fortunately, the H7 controller has a hardware FIFO. This was not used in the existing implementation.
I enabled the FIFO in the code for the H7 controller and have never had a problem with missing bytes since.

As far as I know, using the FIFO has no negative effect on communication behaviour. Therefore, I do not think a configuration option is necessary at this point, and it can always be enabled.

I have tested the new implementation on a STM32H753 succesfully.

Copy link

github-actions bot commented Dec 4, 2024

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@ennyKey
Copy link
Author

ennyKey commented Dec 4, 2024

Side note:
I have seen that there is an option in uart.c line 657 which suggests that the FIFO is enabled for the STM32G4.

However, the HAL_UART_Init(&huart) does not activate the FIFO.
This must be done explicitly by calling HAL_UARTEx_EnableFifoMode(&huart).

As far as I can see, the current implementation for the G4 should run without FIFO despite this line.
Unfortunately I don't have a G4 to check this. So I left the G4 code as it is and made the necessary additions for the H7 only.

@ennyKey ennyKey changed the title ports/stm32: Enable FIFO for H7 controler ports/stm32: Enable FIFO for H7 controler. Dec 4, 2024
@ennyKey ennyKey changed the title ports/stm32: Enable FIFO for H7 controler. ports/stm32: Enable FIFO for H7 controller. Dec 4, 2024
Copy link
Member

@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good improvement, thanks!

The G4 case can be fixed in the future by someone who needs that and has a board to test with.

The H7 has a hardware UART FIFO, so it's worth enabling it, to reduce the
chance of missed incoming characters.  Note that `HAL_UART_Init(&huart)`
does not activate the FIFO, it must be done explicitly by calling
`HAL_UARTEx_EnableFifoMode(&huart)`.

Signed-off-by: ennyKey <ennyKey@fn.de>
@dpgeorge dpgeorge merged commit 2a46759 into micropython:master Jun 26, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants