STM32 RTC的内置晶振的配置流程 ,我是在原子程序原有基础改的不好使

2019-08-17 10:30发布

改成内部晶振 ,还有电池么。
void RTC_Configuration(void)        //RCTÅäÖÃ
{
  /* Enable PWR and BKP clocks */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

  /* Allow access to BKP Domain */
  PWR_BackupAccessCmd(ENABLE);

  /* Reset Backup Domain */
  BKP_DeInit();

  /* Enable LSE */
// RCC_LSEConfig(RCC_LSE_ON);
        RCC_LSICmd(ENABLE);//¿aÆôÄú2¿μíËùê±ÖóLSI
       
       
  /* Wait till LSE is ready */
/* while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
  {iwdg_feed();}*/
        while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
  {iwdg_feed();}
       
iwdg_feed();
  /* Select LSE as RTC Clock Source */
  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
iwdg_feed();
  /* Enable RTC Clock */
  RCC_RTCCLKCmd(ENABLE);
iwdg_feed();
         RTC_WaitForLastTask();
  /* Wait for RTC registers synchronization */
  RTC_WaitForSynchro();
iwdg_feed();
  /* Wait until last write operation on RTC registers has finished */
RTC_EnterConfigMode();//ÔêDíRTCÅäÖÃ
RTC_WaitForLastTask();//μè′yéÏò»′ÎRTCèÎÎñíê3é
        RTC_SetPrescaler(40000);//·ÖÆμoóÎa1HZ
        RTC_WaitForLastTask();//μè′yéÏò»′ÎD′RTCèÎÎñíê3é
        RTC_ITConfig(RTC_IT_ALR , DISABLE);//ê1ÄüÄÖÖóÃëÖD¶Ï
        RTC_WaitForLastTask();//μè′yéÏò»′ÎD′RTCèÎÎñíê3é
        RTC_ExitConfigMode(); //??RTC????
//iwdg_feed();
  /* Enable the RTC Second */
// RTC_ITConfig(RTC_IT_SEC, ENABLE);
//iwdg_feed();
  /* Wait until last write operation on RTC registers has finished */
// RTC_WaitForLastTask();
//iwdg_feed();
  /* Set RTC prescaler: set RTC period to 1sec */
  //RTC_SetPrescaler(32767); /* RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) */
//iwdg_feed();
  /* Wait until last write operation on RTC registers has finished */
// RTC_WaitForLastTask();
}

我只改了这一个函数,其他没有动
0条回答

一周热门 更多>