STM32F103_RTC初始化

2019-08-17 06:34发布

if (BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)
  {
    /* Backup data register value is not correct or not yet programmed (when
       the first time the program is executed) */
    printf(" RTC not yet configured....");
    /* RTC Configuration */
    RTC_Configuration();
    printf(" RTC configured....");
    /* Adjust time by values entered by the user on the hyperterminal */
    Time_Adjust();
    BKP_WriteBackupRegister(BKP_DR1, 0xA5A5);
  }
  else
  {
    /* Check if the Power On Reset flag is set */
    if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)
    {
      printf(" Power On Reset occurred....");
    }
    /* Check if the Pin Reset flag is set */
    else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)
    {
      printf(" External Reset occurred....");
    }
    printf(" No need to configure RTC....");
    /* Wait for RTC registers synchronization */
    RTC_WaitForSynchro();
    /* Enable the RTC Second */
    RTC_ITConfig(RTC_IT_SEC, ENABLE);
    /* Wait until last write operation on RTC registers has finished */
    RTC_WaitForLastTask();
  }

我是参照ST官方提供的RTC初始化例程来的,刚开始运行没什么问题,几天之后再次运行发现程序卡死在"RTC_WaitForSynchro()"这条语句上了,不知道是什么原因。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。