Skip to content

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

Closed
@campag

Description

@campag

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions