7 years, 1 month ago.

STM32L0 RTC with UART

We are using the STM32L073 and the mBed LoRaWAN application. This works fine and provides serial debug on PA2, PA3 at 115200 which is 8us per bit.

However, we wanted to add the RTC. When rtc_init(), is called, the uart speed changes to 28us per bit.

Why is this happening - especially when the RTC runs from a different part of the clock module for the L0 parts.

1 Answer

7 years, 1 month ago.

I checked this example on mbed IDE + NUCLEO_L073RZ (mbed lib v136) and no problem seen with the USART. Can you please share your code ?

#include "mbed.h"

Serial pc(SERIAL_TX, SERIAL_RX);

DigitalOut myled(LED1);

int main()
{
    int i = 1;
    time_t seconds;
    
    pc.baud(115200);
    
    pc.printf("Hello World !\n");
    wait(1);
    
    pc.printf("Hello World again !\n");
    
    set_time(1387188323);
    printf("Date and time are set.\n");
    
    while(1) {
        wait(1);
        pc.printf("This program runs since %d seconds.\n", i++);
        seconds = time(NULL);
        printf("Time as a basic string = %s\n", ctime(&seconds));
        myled = !myled;
    }
}

Use the mBed LoRaWan-demo-76 and target the Nucleo-L073RZ First check the serial output is ok,

Then add a call to rtc_init in main.cpp just before the while(1) main loop. Then the serial output will be corrupted.

posted by Chris Alfred 27 Feb 2017