2015-07-20 06:47 AM
Hello
I have been trying to get the RTC to work with VBAT. I have connected 3V coin cell battery to the VBAT pin (RTC initialized beforehand). I test if RTC is working in the following way:if((RTC->ISR & RTC_ISR_INITS) == 0) {
MX_RTC_Init();
} else {
}
When I run the code (again, RTC is supposed to be initialized), the condition shows that RTC has in fact been initialized, which is confirmed by debugging too. But when I try to otuput the current time, I get constant value which is not changing.
When I initialize RTC in the beginning of my code, it works as expected. I need to be able to keep it going with VBAT though. Any help is welcome.
Thanks
#lse #stm32 #rtc
2015-07-20 09:00 AM
Doesn't seem like a very effective test.
Have you enabled/unlocked access to the RTC/BKP domain?Is the LSE running? Are you looking at the type of reset the processor just went through?Can't help you with Cube/HAL stuff.2015-07-20 10:31 AM
Thanks for the input, clive. The LSE is running; the problem was in the HAL function for reading the Time register. I cannot pinpoint the exact reason, but the HAL function reads the Time register and then corrupts its copy of it. I could see the register is actually incrementing, and implemented my own function for reading the time.
Now RTC works after switching the supply off (it was running before, but the HAL driver could not read the registers). But the HAL drivers appear to contain some nasty bugs.2015-07-20 10:40 AM
But the HAL drivers appear to contain some nasty bugs.
Well there's that, and the awfully convoluted paradigm it implements.