-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STM32F4 RTC broken after soft reset - mbed lib rev 111 #1480
Comments
I added some code to print the RTC registers before and after the set_time call. #include "mbed.h"
int main() {
DigitalIn pb(USER_BUTTON);
Serial usb(USBTX, USBRX);
usb.baud(115200);
while (pb == 1);
usb.printf("starting\r\n");
usb.printf("RTC regs before set_time()\r\n");
usb.printf("RTC TR: %#X\r\n", RTC->TR);
usb.printf("RTC DR: %#X\r\n", RTC->DR);
usb.printf("RTC CR: %#X\r\n", RTC->CR);
usb.printf("RTC ISR: %#X\r\n", RTC->ISR);
usb.printf("RTC PRER: %#X\r\n", RTC->PRER);
usb.printf("RTC WUTR: %#X\r\n", RTC->WUTR);
usb.printf("RTC CALIBR: %#X\r\n", RTC->CALIBR);
usb.printf("RTC ALRMAR: %#X\r\n", RTC->ALRMAR);
usb.printf("RTC ALRMBR: %#X\r\n", RTC->ALRMBR);
usb.printf("RTC WPR: %#X\r\n", RTC->WPR);
usb.printf("RTC SSR: %#X\r\n", RTC->SSR);
usb.printf("RTC SHIFTR: %#X\r\n", RTC->SHIFTR);
usb.printf("RTC TSTR: %#X\r\n", RTC->TSTR);
usb.printf("RTC TSDR: %#X\r\n", RTC->TSDR);
usb.printf("RTC TSSSR: %#X\r\n", RTC->TSSSR);
usb.printf("RTC CALR: %#X\r\n", RTC->CALR);
usb.printf("RTC TAFCR: %#X\r\n", RTC->TAFCR);
usb.printf("RTC ALRMASSR: %#X\r\n", RTC->ALRMASSR);
usb.printf("RTC ALRMBSSR: %#X\r\n", RTC->ALRMBSSR);
set_time(1450813642);
usb.printf("RTC regs after set_time()\r\n");
usb.printf("RTC TR: %#X\r\n", RTC->TR);
usb.printf("RTC DR: %#X\r\n", RTC->DR);
usb.printf("RTC CR: %#X\r\n", RTC->CR);
usb.printf("RTC ISR: %#X\r\n", RTC->ISR);
usb.printf("RTC PRER: %#X\r\n", RTC->PRER);
usb.printf("RTC WUTR: %#X\r\n", RTC->WUTR);
usb.printf("RTC CALIBR: %#X\r\n", RTC->CALIBR);
usb.printf("RTC ALRMAR: %#X\r\n", RTC->ALRMAR);
usb.printf("RTC ALRMBR: %#X\r\n", RTC->ALRMBR);
usb.printf("RTC WPR: %#X\r\n", RTC->WPR);
usb.printf("RTC SSR: %#X\r\n", RTC->SSR);
usb.printf("RTC SHIFTR: %#X\r\n", RTC->SHIFTR);
usb.printf("RTC TSTR: %#X\r\n", RTC->TSTR);
usb.printf("RTC TSDR: %#X\r\n", RTC->TSDR);
usb.printf("RTC TSSSR: %#X\r\n", RTC->TSSSR);
usb.printf("RTC CALR: %#X\r\n", RTC->CALR);
usb.printf("RTC TAFCR: %#X\r\n", RTC->TAFCR);
usb.printf("RTC ALRMASSR: %#X\r\n", RTC->ALRMASSR);
usb.printf("RTC ALRMBSSR: %#X\r\n", RTC->ALRMBSSR);
while (true) {
time_t seconds = time(NULL);
usb.printf("time: %d\r\n", seconds);
wait(5);
}
return 0;
} The results are below. The file "rtc_good.txt" is the results from a cold boot. The file "rtc_bad.txt" is from the soft reset after the boot. I should also note that the time(NULL) calls fail even if set_time() isn't called after a soft reset. |
If the intended behavior could be preserved, that would be valuable. It is useful to be able to keep the RTC running across soft resets or sleep modes and still use the mbed rtc api. |
This commit added a check of the RTC_ISR_INITS flag in the RTC_ISR register in rtc_init(). This change has broken some RTC functionality for at least the STM32F411 processor.
The following code demonstrates the issue. The RTC is set and read properly when the device is cold booted, but a constant value, 946684800, is read from the RTC after a soft reset of the device.
The text was updated successfully, but these errors were encountered: