本帖最后由 lang30 于 2021-12-28 00:37 编辑
换成IRC40K 就能走时;还需要配置哪里呢?
<div class="blockcode"><blockquote>// #define RTC_CLOCK_SOURCE_IRC40K
#define RTC_CLOCK_SOURCE_LXTAL
void rtc_pre_config(void)
{
/* enable access to RTC registers in backup domain */
rcu_periph_clock_enable(RCU_PMU);
pmu_backup_write_enable();
#if defined (RTC_CLOCK_SOURCE_IRC40K)
/* enable the IRC40K oscillator */
rcu_osci_on(RCU_IRC40K);
/* wait till IRC40K is ready */
rcu_osci_stab_wait(RCU_IRC40K);
/* select the RTC clock source */
rcu_rtc_clock_config(RCU_RTCSRC_IRC40K);
prescaler_s = 0x18F;
prescaler_a = 0x63;
#elif defined (RTC_CLOCK_SOURCE_LXTAL)
/* enable the IRC40K oscillator */
rcu_osci_on(RCU_LXTAL);
/* wait till IRC40K is ready */
rcu_osci_stab_wait(RCU_LXTAL);
/* select the RTC clock source */
rcu_rtc_clock_config(RCU_LXTAL);
prescaler_s = 0xFF;
prescaler_a = 0x7F;
#else
#error RTC clock source should be defined.
#endif /* RTC_CLOCK_SOURCE_IRC40K */
rcu_periph_clock_enable(RCU_RTC);
rtc_register_sync_wait();
}
|