← index #15649PR #7056
Related · high · value 3.082
QUERY · ISSUE

NUCLEO-L476RG (STM32L476RG), NUCLEO_G0B1RE (STM32G0B1RE) - LPUART1 initialization not working

openby AndriiHordieievopened 2024-08-13updated 2026-03-24
bugport-stm32

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

CANDIDATE · PULL REQUEST

stm32/boards: expose all 6 available UARTs/USARTs for NUCLEO_L476RG.

closedby aziubinopened 2021-03-20updated 2021-04-13
port-stm32

STM32L476RG mcu of NUCLEO_L476RG board has 6 UART units in total (USART1, USART2, USART3, UART4, UART5 and LPUART1), but only one, UART2 (which is connected to REPL) was defined and available for Python code. Defined are all 5 remaining units including LPUART1.

This pull request resolves the issue with missing UART units in NUCLEO_L476RG board official MicroPython firmware, which affects others, for example:

Tested on real NUCLEO_L476RG board:

MicroPython v1.14-120-g42cf77f48-dirty on 2021-03-20; NUCLEO-L476RG with STM32L476RG
Type "help()" for more information.
>>> print(pyb.UART(3, 9600).write(b'\xff\x01\x86\x00\x00\x00\x00\x00\x79'))
9
>>> print(pyb.UART(1, 9600).write(b'\xff\x01\x86\x00\x00\x00\x00\x00\x79'))
9
>>> print(pyb.UART(4, 9600).write(b'\xff\x01\x86\x00\x00\x00\x00\x00\x79'))
9
>>> print(pyb.UART(5, 9600).write(b'\xff\x01\x86\x00\x00\x00\x00\x00\x79'))
9
>>> print(pyb.UART('LP1',0).write(b'\xff\x01\x86\x00\x00\x00\x00\x00\x79'))
9
>>> print(pyb.UART(6, 0).write(b'\xff\x01\x86\x00\x00\x00\x00\x00\x79'))
9
>>> 

Tested in real scenario using MH-Z19C CO2 sensor with UART interface:

MPY: sync filesystems
MPY: soft reboot
78.723  co2         = 500.00
79.735  co2         = 500.00
80.747  co2         = 500.00
81.759  co2         = 500.00
82.77101  co2         = 500.00
83.784  co2         = 500.00
84.796  co2         = 500.00
85.808  co2         = 500.00
86.82  co2         = 500.00
87.832  co2         = 500.00
88.844  co2         = 500.00

References:

Signed-off-by: Alexander Ziubin aziubin@googlemail.com

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied