static void RTC_Config(void)
{
RTC_InitTypeDef RTC_InitStr;
RTC_TimeTypeDef RTC_TimeStr;
RTC_DateTypeDef RTC_DateStr;
(CLK->ECKCR) |= (uint8_t)0x20;
/* Configures the RTC */
CLK_RTCClockConfig(CLK_RTCCLKSource_LSE, CLK_RTCCLKDiv_1);
/* Wait for LSE clock to be ready */
//while(CLK_GetFlagStatus(CLK_FLAG_LSERDY) == RESET);
while( (CLK->ECKCR) & (uint8_t)(1<<3) == (uint8_t)RESET);
/* wait for 1 second for the LSE Stabilisation */
//LSE_StabTime();
delay_ms(1000);
CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
RTC_InitStr.RTC_HourFormat = RTC_HourFormat_24;
RTC_InitStr.RTC_AsynchPrediv = 127;
RTC_InitStr.RTC_SynchPrediv = 255;
RTC_Init(&RTC_InitStr);
RTC_TimeStructInit(&RTC_TimeStr);
RTC_TimeStr.RTC_Hours = 00;
RTC_TimeStr.RTC_Minutes = 00;
RTC_TimeStr.RTC_Seconds = 00;
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStr);
RTC_DateStructInit(&RTC_DateStr);
//RTC_DateStr.RTC_WeekDay = RTC_Weekday_Tuesday;
RTC_DateStr.RTC_Date = 2;
RTC_DateStr.RTC_Month = RTC_Month_February;
RTC_DateStr.RTC_Year = 19;
RTC_SetDate(RTC_Format_BIN, &RTC_DateStr);
RTC_WakeUpClockConfig(RTC_WakeUpClock_CK_SPRE_16bits);
RTC_ITConfig(RTC_IT_WUT, ENABLE);
/* Enable Interrupts*/
//enableInterrupts(); //open before
}
|