是不是初始化一次之后,以后再启动时就不要再次初始化了?我是这么做的,RTC正确启动之后,在程序中只加入开放BKP访问权的语句,经过半月后,读出的时间是完全正确的。函数如下,除头两句外全//掉了。 大家探讨一下是否正确。 void RTC_Config(void) { RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);/* Enable PWR and BKP clocks */ PWR_BackupAccessCmd(ENABLE); /* Allow access to BKP Domain */ //BKP_DeInit(); /* Reset Backup Domain */
//RCC_LSEConfig(RCC_LSE_ON); /* Enable LSE */ //while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET){}/* Wait till LSE is ready */ //RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);/* Select LSE as RTC Clock Source */ //RCC_RTCCLKCmd(ENABLE);/* Enable RTC Clock */ //RTC_WaitForSynchro(); /* Wait for RTC registers synchronization */ //RTC_WaitForLastTask();/* Wait until last write operation on RTC registers has finished */ //RTC_ITConfig(RTC_IT_SEC, ENABLE);/* Enable the RTC Second */ //RTC_WaitForLastTask();/* Wait until last write operation on RTC registers has finished */ //RTC_SetPrescaler(32767); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */ //RTC_WaitForLastTask(); /* Wait until last write operation on RTC registers has finished */ }
|