我用的是12.5P的晶振,也老是出现上电赶振难的问题.原来想换6P的,但是太难找.通达了解晶振参数.12.5P的晶振赶振到稳定比6P的晶振所需时间长. 而是我对RTC的初始化作而下调整: 这是Keil中RTC例程上修改 /******************************************************************************* * Function Name : RTC_Configuration * Description : Configures the RTC. * Input : None * Output : None * Return : None *******************************************************************************/ void RTC_Configuration(void) { /* 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();
/* Enable LSE */ RCC_LSEConfig(RCC_LSE_ON); /* Wait till LSE is ready */ while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) { }
/* 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(); } 将/* Enable LSE */ RCC_LSEConfig(RCC_LSE_ON); /* Wait till LSE is ready */ while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) { } 改动为: u32 delay; do { for(delay = 0;delay < 90000;delay++); RCC_LSEConfig(RCC_LSE_ON); }while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
现已很好的工作了.已测试好几天从没有再发生上电难振,每次都可以OK.但改回原来的方式则问题又再出现,大家可以试一试. |