I'm trying to implement a battery-backed RTC on an STM32F051 (RTC2 driver).
I've got a 32768Hz crystal connected, which is oscillating.
Using Chibios 3.
I've set STM32_LSECLK to 32768 in the board header file, and STM32_LSE_ENABLED to true in mcuconf.h
According to the RCC->BDCR register, the LSE clock remains disabled, and the RTC is driven from the on-chip 40kHz oscillator (which agrees with my observations - the RTC is running fast).
From what I've read so far, it looks as if I need to change the RTC backup domain, and there's some promising code in hal_lld_backup_domain_init() in hal_lld.c , but I can't see that it's called anywhere.
Is this something that's currently supported?
Battery backed RTC
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Battery backed RTC
Never tested on that specific platform, please verify on the F4 the initialization procedure and call that function on the F0 from the same point.
Giovanni
Giovanni
Re: Battery backed RTC
All the 32F devices have basically the same HAL initialisation.
Having looked more closely, I think I missed that #define STM32_RTCSEL needs to be changed from STM32_RTCSEL_LSI to STM32_RTCSEL_LSE
Will test that in the next few days.
Since the LSE clock is mostly used with the RTC (and can only be used with the RTC, on the F0) might it be appropriate to group LSE and RTC functions together in mcuconf.h? Or even auto-enable LSE if its selected as the RTC clock source?
Having looked more closely, I think I missed that #define STM32_RTCSEL needs to be changed from STM32_RTCSEL_LSI to STM32_RTCSEL_LSE
Will test that in the next few days.
Since the LSE clock is mostly used with the RTC (and can only be used with the RTC, on the F0) might it be appropriate to group LSE and RTC functions together in mcuconf.h? Or even auto-enable LSE if its selected as the RTC clock source?
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Battery backed RTC
I would like to avoid dependencies between the initialization and the various drivers, it would be messy to handle.
Giovanni
Giovanni