您的位置 首页 ADAS

SystemInit()函数的结构剖析

系统函数调用顺序startup_stm32f10x_clsrarr;SystemInit()rarr;SetSysClock()rarr;SetSysClockTo72()总结:开始是在keil4里看

体系函数调用次序startup_stm32f10x_cl.s→ SystemInit() → SetSysClock()→ SetSysClockTo72()

总结:开端是在keil4里看代码,很紊乱,后来把他粘到Notepad编辑器,一点击就可以看出这个子函数到哪完毕

[cpp]view plaincopy

  1. #ifdefined(STM32F10X_LD_VL)||(definedSTM32F10X_MD_VL)||(definedSTM32F10X_HD_VL)
  2. /*#defineSYSCLK_FREQ_HSEHSE_VALUE*/
  3. #defineSYSCLK_FREQ_24MHz24000000
  4. #else
  5. /*#defineSYSCLK_FREQ_HSEHSE_VALUE*/
  6. /*#defineSYSCLK_FREQ_24MHz24000000*/
  7. /*#defineSYSCLK_FREQ_36MHz36000000*/
  8. /*#defineSYSCLK_FREQ_48MHz48000000*/
  9. /*#defineSYSCLK_FREQ_56MHz56000000*/
  10. #defineSYSCLK_FREQ_72MHz72000000
  11. #endif

下面界说的SystemCoreClock 变量是为了便利取出几种情况下体系时钟的实践值,例SYSCLK_FREQ_24MHz 也便是24000000。

[cpp]view plaincopy

  1. #ifdefSYSCLK_FREQ_HSE
  2. uint32_tSystemCoreClock=SYSCLK_FREQ_HSE;/*!equency(CoreClock)*/
  3. #elifdefinedSYSCLK_FREQ_24MHz
  4. uint32_tSystemCoreClock=SYSCLK_FREQ_24MHz;/*!
  5. #elifdefinedSYSCLK_FREQ_36MHz
  6. uint32_tSystemCoreClock=SYSCLK_FREQ_36MHz;/*!
  7. #elifdefinedSYSCLK_FREQ_48MHz
  8. uint32_tSystemCoreClock=SYSCLK_FREQ_48MHz;/*!
  9. #elifdefinedSYSCLK_FREQ_56MHz
  10. uint32_tSystemCoreClock=SYSCLK_FREQ_56MHz;/*!
  11. #elifdefinedSYSCLK_FREQ_72MHz
  12. uint32_tSystemCoreClock=SYSCLK_FREQ_72MHz;/*!
  13. #else/*!
  14. uint32_tSystemCoreClock=HSI_VALUE;/*!
  15. #endif

[cpp]view plaincopy

  1. staticvoidSetSysClock(void)
  2. {
  3. #ifdefSYSCLK_FREQ_HSE
  4. SetSysClockToHSE();
  5. #elifdefinedSYSCLK_FREQ_24MHz
  6. SetSysClockTo24();
  7. #elifdefinedSYSCLK_FREQ_36MHz
  8. SetSysClockTo36();
  9. #elifdefinedSYSCLK_FREQ_48MHz
  10. SetSysClockTo48();
  11. #elifdefinedSYSCLK_FREQ_56MHz
  12. SetSysClockTo56();
  13. #elifdefinedSYSCLK_FREQ_72MHz
  14. SetSysClockTo72();
  15. #endif
  16. /*Ifnoneofthedefineaboveisenabled,theHSIisusedasSystemclock
  17. source(defaultafterreset)*/
  18. }

[cpp]view plaincopy

  1. #ifdefSYSCLK_FREQ_HSE
  2. /**
  3. *@briefSelectsHSEasSystemclocksourceandconfigureHCLK,PCLK2
  4. *andPCLK1prescalers.
  5. *@noteThisfunctionshouldbeusedonlyafterreset.
  6. *@paramNone
  7. *@retvalNone
  8. */
  9. staticvoidSetSysClockToHSE(void)
  10. {
  11. ……
  12. }

[cpp]view plaincopy

  1. #elifdefinedSYSCLK_FREQ_24MHz
  2. /**
  3. *@briefSetsSystemclockfrequencyto24MHzandconfigureHCLK,PCLK2
  4. *andPCLK1prescalers.
  5. *@noteThisfunctionshouldbeusedonlyafterreset.
  6. *@paramNone
  7. *@retvalNone
  8. */
  9. staticvoidSetSysClockTo24(void)
  10. {
  11. ……..
  12. }

[cpp]view plaincopy

  1. #elifdefinedSYSCLK_FREQ_36MHz
  2. /**
  3. *@briefSetsSystemclockfrequencyto36MHzandconfigureHCLK,PCLK2
  4. *andPCLK1prescalers.
  5. *@noteThisfunctionshouldbeusedonlyafterreset.
  6. *@paramNone
  7. *@retvalNone
  8. */
  9. staticvoidSetSysClockTo36(void)
  10. {
  11. ……
  12. }

省掉几个……

[cpp]view plaincopy

  1. #elifdefinedSYSCLK_FREQ_72MHz
  2. /**
  3. *@briefSetsSystemclockfrequencyto72MHzandconfigureHCLK,PCLK2
  4. *andPCLK1prescalers.
  5. *@noteThisfunctionshouldbeusedonlyafterreset.
  6. *@paramNone
  7. *@retvalNone
  8. */
  9. staticvoidSetSysClockTo72(void)
  10. {
  11. …….
  12. }

这样结构就很清楚了。

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/adas/261446.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部