Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 11 months ago.
Function set_time with STM32L053 and internal RTC clock source
Hello, I have the board with STM32L053 MCU and without external 32.768khz clock source. And I need to setup RTC. I'm trying this code:
Code
#include "mbed.h" Serial terminal(PA_9, PA_10); DigitalOut led1(PA_3); void toggle_led() { led1 = !led1; } int main() { set_time(1256729737); time_t seconds = time(NULL); terminal.printf("Seconds since January 1, 1970: %d\n", seconds); ... }
And there's no any response after set_time function, Console is empty. How could I fix that?
THanks
1 Answer
7 years, 11 months ago.
I cannot tell much for the L0, however I am working with the STM32L4. The L4 Nucleo board uses a 32k crystal which means the RTC clock works independent of the MCU clock. set_time works for me on L4.
However it depends how the mbed OS is configured, the L4 version exspectes that the RTC crystal (LSE) is available otherwise it will hang at set_time.
You can have a look into the mbed source at rtc_api.c in the STM HAL code.