本帖最后由 charrijon 于 2014-6-19 21:17 编辑
void RTC_Configuration(void)
{ uint16_t delay = 0;
/* Enable PWR and BKP clocks */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* Allow access to BKP Domain */
PWR_BackupAccessCmd(ENABLE);
/* Reset Backup Domain */
BKP_DeInit();
// do
// { for(delay = 0;delay < 90000;delay++);
// RCC_LSEConfig(RCC_LSE_ON);
// }while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET);
/* Enable LSE */
RCC_LSEConfig(RCC_LSE_ON);
/* Wait till LSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET){}
printf( "\r\n aaaaa\r\n " );
/* Select LSE as RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
/* Enable RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* Wait for RTC registers synchronization */
RTC_WaitForSynchro();
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Enable the RTC Second */
RTC_ITConfig(RTC_IT_SEC, ENABLE);
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
/* Set RTC prescaler: set RTC period to 1sec */
RTC_SetPrescaler(32767); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();
}
为什么st提供的初始化程序包含这么多死循环?目前碰到RTC晶振不起振的问题,导致整个软件都运行不了,为了RTC影响了整个软件的运行,这个芯片能用到大批量的产品上吗 |