cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F411RE - RTC and VBAT

tbnkr
Associate II
Posted on July 20, 2015 at 15:47

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
3 REPLIES 3
Posted on July 20, 2015 at 18:00

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.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
tbnkr
Associate II
Posted on July 20, 2015 at 19:31

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.

Posted on July 20, 2015 at 19:40

But the HAL drivers appear to contain some nasty bugs. 

Well there's that, and the awfully convoluted paradigm it implements.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..