STM32F4 RTC Çalıştıramadım (ÇÖZÜLDÜ)

Başlatan respected, 10 Temmuz 2013, 16:53:13

respected

RTC yi kurmak için bu fonksiyonu yazdım.
void RTC_kur(void)
{
  
  /* Enable the PWR clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

  /* Allow access to RTC */
//   PWR_BackupAccessCmd(ENABLE);
    
// #if defined (RTC_CLOCK_SOURCE_LSI)  /* 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);
  
//   /* ck_spre(1Hz) = RTCCLK(LSI) /(uwAsynchPrediv + 1)*(uwSynchPrediv + 1)*/
//   uwSynchPrediv = 0xFF;
//   uwAsynchPrediv = 0x7F;

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

  /* Wait for RTC APB registers synchronisation */
  RTC_WaitForSynchro();
  
  /* Configure the RTC data register and RTC prescaler */
  RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
  RTC_InitStructure.RTC_SynchPrediv = 0xFF;
  RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
  RTC_Init(&RTC_InitStructure);

  
  /* Set the date: Friday January 11th 2013 */
  RTC_DateStructure.RTC_Year = 0x13;
  RTC_DateStructure.RTC_Month = RTC_Month_January;
  RTC_DateStructure.RTC_Date = 0x11;
  RTC_DateStructure.RTC_WeekDay = RTC_Weekday_Saturday;
  RTC_SetDate(RTC_Format_BCD, &RTC_DateStructure);
  
  /* Set the time to 05h 20mn 00s AM */
  RTC_TimeStructure.RTC_H12     = RTC_H12_AM;
  RTC_TimeStructure.RTC_Hours   = 0x05;
  RTC_TimeStructure.RTC_Minutes = 0x20;
  RTC_TimeStructure.RTC_Seconds = 0x00; 
  
  RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);   
  
  /* Indicator for the RTC configuration */
  RTC_WriteBackupRegister(RTC_BKP_DR0, 0x32F2);
}



while içerisinde ise
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);	
	sprintf(zaman,"%0.2x", RTC_TimeStructure.RTC_Hours);
LCD_WriteData(zaman);

bu kodları yazıyorum. Değer 0 gösteriyor.  RTC_Hours değişkenine program içerinde değer versem bile sıfırlıyor.

Nerede hata yapıyorum acaba?


PWR_BackupAccessCmd(ENABLE); Satırı aktif hale gelecekmiş. Bunun içinde projeye stm32f4xx_pwr.c dosyasının eklenmesi gerekiyormuş.