Skip to content

Conversation

@yn386
Copy link
Contributor

@yn386 yn386 commented Sep 15, 2025

Summary

UART prescaler value should set up collectly to initialize LPUART with low baudrate for STM32G0/G4/H5.
This can be implemented similarly to STM32H7/N6/WB.

The following code does not work:

from machine import UART
uart = UART('LP1', baudrate=9600, bits=8, parity=None, stop=1)

An error occured with following message:

ValueError: set baudrate 0 is not within 5% of desired value

LPUART should be initialized without errors.

Testing

Tested with:

  • NUCLEO-G01RB
  • NUCLEO-G474RE
  • NUCLEO-H563ZI

Remarks

STM32WL may have same issue but I couldn't check because I don't have it.

@github-actions
Copy link

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

UART prescaler value should set up correctly to initialize LPUART with low
baudrate for STM32G0/G4/H5.  This can be implemented similarly to
STM32H7/N6/WB.

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
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.

Looks good, thanks!

@dpgeorge dpgeorge merged commit c4d99f3 into micropython:master Sep 18, 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