微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > STM32 RTC时钟源LSE

STM32 RTC时钟源LSE

时间:11-17 来源:互联网 点击:

  1. 存器1的值为0XA5A5*/
  2. BKP_WriteBackupRegister(BKP_DR1,RTC_SEQ_ID);
  3. }else
  4. {
  5. /*CheckifthePowerOnResetflagisset*/
  6. //RCC_GetFlagStatus(RCC_FLAG_PORRST)!=RESET
  7. //printf("\r\n\nPowerOnResetoccurred....");
  8. /*CheckifthePinResetflagisset*/
  9. //elseif(RCC_GetFlagStatus(RCC_FLAG_PINRST)!=RESET)
  10. //printf("\r\n\nExternalResetoccurred....");
  11. if(RCC_GetFlagStatus(RCC_FLAG_LSERDY)==RESET)
  12. {
  13. //RCC->CSR|=0x1;//开启内部低速晶振
  14. //while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY)==RESET);
  15. //RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);//使用LSI提供RTC时钟
  16. //RCC_RTCCLKConfig(RCC_RTCCLKSource_HSE_Div128);
  17. RTC_Configuration();
  18. }
  19. //printf("\r\nNoneedtoconfigureRTC....");
  20. /*WaitforRTCregisterssynchronization*/
  21. RTC_WaitForSynchro();
  22. /*EnabletheRTCSecond*/
  23. RTC_ITConfig(RTC_IT_SEC,ENABLE);
  24. /*WaituntillastwriteoperationonRTCregistershasfinished*/
  25. RTC_WaitForLastTask();
  26. }
  27. #ifdefRTCClockOutput_Enable
  28. /*EnablePWRandBKPclocks*/
  29. RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR|RCC_APB1Periph_BKP,ENABLE);
  30. /*AllowaccesstoBKPDomain*/
  31. PWR_BackupAccessCmd(ENABLE);
  32. /*DisabletheTamperPin*/
  33. BKP_TamperPinCmd(DISABLE);/*TooutputRTCCLK/64onTamperpin,thetamper
  34. functionalitymustbedisabled*/
  35. /*EnableRTCClockOutputonTamperPin*/
  36. BKP_RTCOutputConfig(BKP_RTCOutputSource_CalibClock);
  37. #endif
  38. /*Clearresetflags*/
  39. RCC_ClearFlag();
  40. }



实际测试,RTC效果还行,然后配合上位机隔一定的时间后同步时间基本上能够满足要求。

万恶的LSE晶振,这东西简直不能忍受......

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top