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;
rcu_rtc_clock_config(RCU_LXTAL);中的RCU_LXTAL这个参数是错的,应该使用RCU_RTCSRC_LXTAL。
|