Skip to content
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

STM32 RTC backup registers get reset when setting the clock #1634

Closed
campag opened this issue Mar 26, 2016 · 6 comments
Closed

STM32 RTC backup registers get reset when setting the clock #1634

campag opened this issue Mar 26, 2016 · 6 comments

Comments

@campag
Copy link

campag commented Mar 26, 2016

I started to use the RTC backup registers on Nucleo F401 with the HAL library, but notice that if I set the time with mbed, my data is also erased - mbed's set_time() in rtc_time.c calls rtc_init() before rtc_write().

However STM32F4's (& I suppose others) rtc_init() in rtc_api.c erases the backup registers. If I comment out

/*
        __HAL_RCC_BACKUPRESET_FORCE();
        __HAL_RCC_BACKUPRESET_RELEASE();
*/

then my backup register data is untouched.

Is there a reason those lines are there? After all, mbed api doesn't use the backup registers, and they appear to be reset anyway on power-up with no separate coin-cell Vbat present.

@0xc0170
Copy link
Contributor

0xc0170 commented Mar 26, 2016

cc @bcostm @adustm

@bcostm
Copy link
Contributor

bcostm commented Mar 31, 2016

We made some trials and these 2 lines are only needed when the LSI is used. For the LSE, they can be removed. What we are going to do is to move these 2 lines in the LSI section only.

@campag
Copy link
Author

campag commented Mar 31, 2016

Thanks for looking at this. Current Nucleo production seems to be fitted with LSE, so the fix is fine there.

I guess it won't be of use to those with older models & LSI though, and somewhat ironically those are the ones who will be setting the clock most often.

For those wanting to play with the backup registers under mbed, I put example code on my notebook.

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 13, 2016

@campag is this resolved, or still relevant?

@campag
Copy link
Author

campag commented Apr 13, 2016

Resolved thanks. Will close but one quick question - where should I report small issue with the STM HAL library (re ADC from temp & Vbat). Doesn't seem appropriate here?

@campag campag closed this as completed Apr 15, 2016
@bcostm
Copy link
Contributor

bcostm commented Apr 22, 2016

For the support of ADC internal channels (Vbat, Vref, Temp) you can enter an issue. We have started to doing it on mbedOS. It could be easily ported to mbedClassic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants