Our STM32F103VE board has a battery backup for the RTC ... in hal_lld.c I see
/* PWR and BD clocks enabled. */
rccEnablePWRInterface(FALSE);
rccEnableBKPInterface(FALSE);
Looking at the STM specs these appear to set registers that enable an RTC backup timer. I've tried setting these TRUE, but in both cases while the RTC value is maintained when power is off, it's not being updated, which is what I want to achieve. My understanding is that this should be possible.
I read the above code to mean that PWR and BD are in fact disabled when 2.4 boots. Would you clarify this please?
regards
SD
Turn on RTC battery backup
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Turn on RTC battery backup
Hi,
Are you sure that the external 32K oscillator works while the device is under battery power? it is possible it is not running and the RTC does not increase.
Giovanni
Are you sure that the external 32K oscillator works while the device is under battery power? it is possible it is not running and the RTC does not increase.
Giovanni
Re: Turn on RTC battery backup
Hi
That code just enable access to RTC registers via AHB1 bus, it not starts RTC cell. RTC enables in halInit() function. Did you forget about
Switching argument of rccEnablePWRInterface(FALSE); to TRUE enables power saving mode.
rallysjd wrote:/* PWR and BD clocks enabled. */
rccEnablePWRInterface(FALSE);
rccEnableBKPInterface(FALSE);
That code just enable access to RTC registers via AHB1 bus, it not starts RTC cell. RTC enables in halInit() function. Did you forget about
Code: Select all
#define HAL_USE_RTC TRUESwitching argument of rccEnablePWRInterface(FALSE); to TRUE enables power saving mode.
Re: Turn on RTC battery backup
Found it. Here's how to get it working.
In mcuconf.h
the internal high speed clock is the default for the RTC tick over. This has to be changed to use the external 32KHz clock.
#define STM32_HSE_ENABLED TRUE
#define STM32_LSE_ENABLED TRUE
#define STM32_RTCSEL STM32_RTCSEL_LSE // was STM32_RTCSEL_HSEDIV
With STM32_RTCSEL_HSEDIV used, the RTC value is retained when the board power is removed, but the clock does not tick over on battery power.
SD.
In mcuconf.h
the internal high speed clock is the default for the RTC tick over. This has to be changed to use the external 32KHz clock.
#define STM32_HSE_ENABLED TRUE
#define STM32_LSE_ENABLED TRUE
#define STM32_RTCSEL STM32_RTCSEL_LSE // was STM32_RTCSEL_HSEDIV
With STM32_RTCSEL_HSEDIV used, the RTC value is retained when the board power is removed, but the clock does not tick over on battery power.
SD.