Due to RTC example in APM32F0xx SDK,RTC clock is LSI,I want to use LSE,what should I do?
We just need to modify the RTC_Init() function,here is the revised version.
void RTC_Init(void)
{
RTC_Config_T Struct;
/* Enable PMU Periph Clock */
RCM_EnableAPB1PeriphClock(RCM_APB1_PERIPH_PMU);
/* Backup Access */
PMU_EnableBackupAccess();
/* Enable LSI */
//RCM_EnableLSI();
//RCM->BDCTRL_B.LSEEN = BIT_SET;
RCM_ConfigLSE(RCM_LSE_OPEN);
/* Wait until LSI is ready */
//while (RCM_ReadStatusFlag(RCM_FLAG_LSIRDY) == RESET)
//{
//}
while (RCM_ReadStatusFlag(RCM_FLAG_LSERDY) == RESET)
{
}
/* Select LICT as RCM clock */
//RCM_ConfigRTCCLK(RCM_RTCCLK_LSI);
RCM_ConfigRTCCLK(RCM_RTCCLK_LSE);
/* Enable RTC clock */
RCM_EnableRTCCLK();
/* Disable RTC write Protection */
RTC_DisableWriteProtection();
/* Wait Synchro */
RTC_WaitForSynchro();
/* set LSI Prediv */
RTC_ConfigStructInit(&Struct);
Struct.AsynchPrediv = 0X7F;
Struct.SynchPrediv = 0XFF;
RTC_Config(&Struct);
}