AnsweredAssumed Answered

RTC write

Question asked by kaka on Oct 12, 2015
Latest reply on Oct 13, 2015 by Clive One
hi 
can anyone tel me what wrong with the below code ?..i cant bale to write 



void rtc_Initialize()
{


     int i = 0 ;


     RTC_TimeTypeDef RTC_TimeStruct;




      SystemInit();
     /* Enable the PWR clock */
       RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);


       /* Allow access to RTC */
       PWR_BackupAccessCmd(ENABLE);


     /***Configures the External Low Speed oscillator (LSE)****/


       RCC_LSEConfig(RCC_LSE_ON);


       /* Wait till LSE is ready */
      // while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET){};


       /* Select the RTC Clock Source */
       RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);


       /* Enable the RTC Clock */
       RCC_RTCCLKCmd(ENABLE);


       /* Wait for RTC APB registers synchronisation */
       RTC_WaitForSynchro();


       /* Calendar Configuration with LSI supposed at 32KHz */
       RTC_InitTypeDef RTC_InitStructure;
       RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
       RTC_InitStructure.RTC_SynchPrediv =  0xFF; /// final one is 1hz
       RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
       RTC_Init(&RTC_InitStructure);


       RTC_TimeStruct.RTC_H12 = RTC_H12_AM ;
       RTC_TimeStruct.RTC_Hours = 10;
       RTC_TimeStruct.RTC_Minutes = 30;
       RTC_TimeStruct.RTC_Seconds = 0;
       RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);




       for(i = 0; i < 100000; i++);


            while(1)
            {


                 RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
            }




}

Outcomes