2014-11-24 04:35 AM
Hello.
I have a problem with set time. When I config time on program start, time is ok, but after, I can not set new time.This is a code:void RTC_Config(void){ RTC_InitTypeDef RTC_InitStructure; RTC_TimeTypeDef RTC_TimeStructure; RTC_DateTypeDef RTC_DateStructure; /* Enable the PWR clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); /* Allow access to RTC */ PWR_BackupAccessCmd(ENABLE); /* LSI used as RTC source clock */ /* The RTC Clock may varies due to LSI frequency dispersion. */ /* Enable the LSI OSC */ RCC_LSICmd(ENABLE); /* Wait till LSI is ready */ while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) { } /* Select the RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); /* Enable the RTC Clock */ RCC_RTCCLKCmd(ENABLE); /* Wait for RTC APB registers synchronisation */ RTC_WaitForSynchro(); /* Calendar Configuration with LSI supposed at 32KHz */ RTC_InitStructure.RTC_AsynchPrediv = 0x7F; RTC_InitStructure.RTC_SynchPrediv = 0xFF; /* (32KHz / 128) - 1 = 0xFF*/ RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; RTC_Init(&RTC_InitStructure); RTC_TimeStructure.RTC_Seconds = 0; RTC_TimeStructure.RTC_Minutes = 5; RTC_TimeStructure.RTC_Hours = 14; RTC_SetTime(RTC_Format_BIN, &RTC_TimeStructure); RTC_DateStructure.RTC_Date = 19; RTC_DateStructure.RTC_Month = 11; RTC_DateStructure.RTC_WeekDay= RTC_Weekday_Wednesday; RTC_DateStructure.RTC_Year = 14; RTC_SetDate(RTC_Format_BIN, &RTC_DateStructure);}Code for new time:RTC_TimeStructure.RTC_Seconds = 0;RTC_TimeStructure.RTC_Minutes = 1;RTC_TimeStructure.RTC_Hours = 11;RTC_SetTime(RTC_Format_BIN, &RTC_TimeStructure);RTC_DateStructure.RTC_Date = 11;RTC_DateStructure.RTC_Month = 12;RTC_DateStructure.RTC_WeekDay= RTC_Weekday_Wednesday;RTC_DateStructure.RTC_Year = 12;RTC_SetDate(RTC_Format_BIN, &RTC_DateStructure); #lsi #date #rtc #time2015-10-01 12:58 AM