目前配置的只能是当天的闹钟,如何做到每天在设置的那个时间点进闹钟呢?哪位大佬帮忙解答下。gd32跟STM32不太一样,没法参照。以下是我做的闹钟代码,该如何修改成每天的闹钟。用的是库函数提供的寄存器操作方法。
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_IRC32K)
rcu_osci_on(RCU_IRC32K);
while(ERROR == rcu_osci_stab_wait(RCU_IRC32K));
rcu_rtc_clock_config(RCU_RTCSRC_IRC32K);
prescaler_a = 0x63; //ck_apre频率 = RTC_CLOCK/(prescaler_a+1) = 32000/(99+1)=320HZ
prescaler_s = 0x13F; //ck_spre频率 = ck_apre/(prescaler_s+1) = 320/(319+1)=1HZ
#elif defined (RTC_CLOCK_SOURCE_LXTAL)
rcu_osci_on(RCU_LXTAL);
rcu_osci_stab_wait(RCU_LXTAL);
rcu_rtc_clock_config(RCU_RTCSRC_LXTAL);
prescaler_s = 0xFF;
prescaler_a = 0x7F;
#else
#error RTC clock source should be defined
#endif
rcu_periph_clock_enable(RCU_RTC);
rtc_register_sync_wait();
}
|