← index #15649PR #7059
Related · high · value 3.287
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

ports/stm32/boards/NUCLEO_L476RG/mpconfigboard: Added 5 reamining UARTs.

closedby aziubinopened 2021-03-21updated 2021-04-10
port-stm32

STM32L476RG mcu of NUCLEO_L476RG board has 6 UART/USART units in total (USART1, USART2, USART3, UART4, UART5 and LPUART1), but only UART2, which is connected to REPL, is defined and available for Python code. As a result there is currently no possibility to use serial communication with external devices (like MH-Z19 sensor) together with REPL.

This pull request resolves this issue with missing UART units in NUCLEO_L476RG board official MicroPython firmware, which also affected others multiple times, 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