各位大神,我在用GD32F107VC的RTC时,使用LSE做时钟源,但是LSE一直不ready,下面是RTC配置(例程),求助~~~~,不知道问题在哪。
/* Enable PWR and BKP clocks */
RCC_APB1PeriphClock_Enable(RCC_APB1PERIPH_PWR | RCC_APB1PERIPH_BKP, ENABLE);
/* Allow access to BKP Domain */
PWR_BackupAccess_Enable(ENABLE);
/* Reset Backup Domain */
BKP_DeInit();
/* Enable LSE */
RCC_LSEConfig(RCC_LSE_EN);
/* Wait till LSE is ready */
while (RCC_GetBitState(RCC_FLAG_LSESTB) == RESET)
{
}
/* Select LSE as RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSOURCE_LSE);
/* Enable RTC Clock */
RCC_RTCCLK_Enable(ENABLE);
/* Wait for RTC registers synchronization */
RTC_WaitRSF();
/* Wait until last write operation on RTC registers has finished */
RTC_WaitLWOFF();
/* Enable the RTC Second */
RTC_INT_Enable(RTC_INT_SF, ENABLE);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitLWOFF();
/* Set RTC prescaler: set RTC period to 1sec */
RTC_SetPrescaler(32767);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitLWOFF(); |