Report
1 year, 8 months ago.

How can I use LPUART on NUCLEO_L476RG ?

Hi, everyone

When I declare serial instance which uses LPUART port like below, I found "Cannot initialize UART" error log.

- Serial lpuart_port0(PC_1, PC_0);

To use it, shall I initialize something ?

Please let me know how.

Thanks

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32L476RGT6 microcontroller.
Comment on this question

1 Answer

1 year, 8 months ago.

Dear Simho,

Thank you for reporting the issue, I have been able to reproduce it.

As stated in the reference manual of STM32L476, the system clock should be in the range of [3 x baudrate ... 4096 x baudrate]

In mbed-os, there is a fixed system clock of 80MHz for NUCLEO_L476RG and a default baudrate at 9600. This cannot work.

At 80MHz, you can reach a range of baudrate between 19 531 and 26 666 666 bps. We will fix this in the arm / mbed-os database, but in the meanwhile you can either patch the system clock so that it become less than 39MHz, or you can change the default baud rate to 115200, for instance.

File: mbed-os/targets/TARGET_STM/TARGET_STM32L4/serial_device.c, line 126 change 9600 to 115200

    // Configure UART
    obj_s->baudrate = 115200;

Kind regards Armelle

Issue created in gihub: https://github.com/ARMmbed/mbed-os/issues/5389

posted by Armelle DubocST 27 Oct 2017

Hi Patch available: https://github.com/ARMmbed/mbed-os/pull/5570 Thx

posted by Jerome Coutant 23 Nov 2017