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, 5 months ago.
rtc hangs/freezes on set_time() on stm32f103c8t6
Connected 3.2v battery on vbat, and tried RTC samples.
The program hangs on call of set_time function.
#include "stm32f103c8t6.h" //#include "rtc_api.h" #include "stdio.h" #include "mbed.h" int main() { ... set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37 while (true) { time_t seconds = time(NULL); myLCD.printf("Time as seconds since January 1, 1970 = %d\n", seconds); ... wait(1); } ... }
rtc_init(); also hangs the program.
if I skip set_time (or rtc_init), program does not hang but time(NULL) returns -1
Thanks.
1 Answer
6 years, 9 months ago.
Try this, guys:
https://os.mbed.com/users/maxxir/code/Nucleo_F103RB_RTC_battery_bkup_pwr_off_o/
Hello Boban,
posted by Zoltan Hudak 18 Feb 2017According to the reference manual, chapter 5.1.2 "Battery backup domain", the VBAT pin powers the RTC unit, the LSE oscillator and the PC13 to PC15 IOs, allowing the RTC to operate even when the main digital supply (VDD) is turned off. But I don't think you can print or display anything while the VDD is off. Nevertheless, when the VDD is recovered the program shall resume to run without resetting the RTC and loosing the time information while the VDD was down. Unfortunately, as I know this did not work on the ST mbed boards in the past. Despite of this announcement I'm not sure that it has been fixed also for the NUCLEO-F103RB platform. At least it isn't on the list of tested boards.
Just to confirm that this does not work on STM32F103VET6 also... :(
posted by Boban Velickovic 12 Mar 2017