NUCLEO-L476RG (STM32L476RG), NUCLEO_G0B1RE (STM32G0B1RE) - LPUART1 initialization not working
Port, board and/or hardware
port-stm32 - NUCLEO-L476RG with STM32L476RG
MicroPython version
MicroPython v1.23.0 on 2024-06-02; NUCLEO-L476RG with STM32L476RG
Reproduction
from machine import UART
uart = UART('LP1', baudrate=9600, bits=8, parity=None, stop=1)
or
from machine import UART
uart = UART(6, baudrate=9600, bits=8, parity=None, stop=1)
Expected behaviour
LPUART should initialize without errors
Observed behaviour
ValueError: set baudrate 0 is not within 5% of desired value
Additional Information
Similar issue https://github.com/micropython/micropython/issues/7466
Code of Conduct
Yes, I agree
stm32: Fix LPUART init failure with low baudrate.
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.