void RTC_Configuration(void) { u32 delay; /* 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 { //delay about 0.1ms for(delay = 0;delay < 5000;delay++); // Enable HSE RCC_LSEConfig(RCC_LSE_ON); } while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET); // Select HSE as RTC Clock Source RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
/* Enable RTC Clock */ RCC_RTCCLKCmd(ENABLE);
#ifdef RTCClockOutput_Enable /* Disable the Tamper Pin */ BKP_TamperPinCmd(DISABLE); /* To output RTCCLK/64 on Tamper pin, the tamper functionality must be disabled */ /* Enable RTC Clock Output on Tamper Pin */ BKP_RTCCalibrationClockOutputCmd(ENABLE); #endif
/* 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) */ //RTC_SetPrescaler(62499); /* RTC period = RTCCLK/RTC_PR = (8M/128=62.5kHz)/(62499+1) */ /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); /* To output second signal on Tamper pin, the tamper functionality must be disabled (by default this functionality is disabled) */ BKP_TamperPinCmd(DISABLE);
/* Enable the RTC Second Output on Tamper Pin */ BKP_RTCOutputConfig(BKP_RTCOutputSource_Second); }
仅仅修改使用外部低速晶振后,CPU状态指示灯的关启周期由2秒变为8.4秒,请问为什么? |