体系函数调用次序startup_stm32f10x_cl.s→ SystemInit() → SetSysClock()→ SetSysClockTo72()
总结:开端是在keil4里看代码,很紊乱,后来把他粘到Notepad编辑器,一点击就可以看出这个子函数到哪完毕
[cpp]view plaincopy
- #ifdefined(STM32F10X_LD_VL)||(definedSTM32F10X_MD_VL)||(definedSTM32F10X_HD_VL)
- /*#defineSYSCLK_FREQ_HSEHSE_VALUE*/
- #defineSYSCLK_FREQ_24MHz24000000
- #else
- /*#defineSYSCLK_FREQ_HSEHSE_VALUE*/
- /*#defineSYSCLK_FREQ_24MHz24000000*/
- /*#defineSYSCLK_FREQ_36MHz36000000*/
- /*#defineSYSCLK_FREQ_48MHz48000000*/
- /*#defineSYSCLK_FREQ_56MHz56000000*/
- #defineSYSCLK_FREQ_72MHz72000000
- #endif
下面界说的SystemCoreClock 变量是为了便利取出几种情况下体系时钟的实践值,例SYSCLK_FREQ_24MHz 也便是24000000。
[cpp]view plaincopy
- #ifdefSYSCLK_FREQ_HSE
- uint32_tSystemCoreClock=SYSCLK_FREQ_HSE;/*!
equency(CoreClock)*/ - #elifdefinedSYSCLK_FREQ_24MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_24MHz;/*!
- #elifdefinedSYSCLK_FREQ_36MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_36MHz;/*!
- #elifdefinedSYSCLK_FREQ_48MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_48MHz;/*!
- #elifdefinedSYSCLK_FREQ_56MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_56MHz;/*!
- #elifdefinedSYSCLK_FREQ_72MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_72MHz;/*!
- #else/*!
- uint32_tSystemCoreClock=HSI_VALUE;/*!
- #endif
[cpp]view plaincopy
- staticvoidSetSysClock(void)
- {
- #ifdefSYSCLK_FREQ_HSE
- SetSysClockToHSE();
- #elifdefinedSYSCLK_FREQ_24MHz
- SetSysClockTo24();
- #elifdefinedSYSCLK_FREQ_36MHz
- SetSysClockTo36();
- #elifdefinedSYSCLK_FREQ_48MHz
- SetSysClockTo48();
- #elifdefinedSYSCLK_FREQ_56MHz
- SetSysClockTo56();
- #elifdefinedSYSCLK_FREQ_72MHz
- SetSysClockTo72();
- #endif
- /*Ifnoneofthedefineaboveisenabled,theHSIisusedasSystemclock
- source(defaultafterreset)*/
- }
[cpp]view plaincopy
- #ifdefSYSCLK_FREQ_HSE
- /**
- *@briefSelectsHSEasSystemclocksourceandconfigureHCLK,PCLK2
- *andPCLK1prescalers.
- *@noteThisfunctionshouldbeusedonlyafterreset.
- *@paramNone
- *@retvalNone
- */
- staticvoidSetSysClockToHSE(void)
- {
- ……
- }
[cpp]view plaincopy
- #elifdefinedSYSCLK_FREQ_24MHz
- /**
- *@briefSetsSystemclockfrequencyto24MHzandconfigureHCLK,PCLK2
- *andPCLK1prescalers.
- *@noteThisfunctionshouldbeusedonlyafterreset.
- *@paramNone
- *@retvalNone
- */
- staticvoidSetSysClockTo24(void)
- {
- ……..
- }
[cpp]view plaincopy
- #elifdefinedSYSCLK_FREQ_36MHz
- /**
- *@briefSetsSystemclockfrequencyto36MHzandconfigureHCLK,PCLK2
- *andPCLK1prescalers.
- *@noteThisfunctionshouldbeusedonlyafterreset.
- *@paramNone
- *@retvalNone
- */
- staticvoidSetSysClockTo36(void)
- {
- ……
- }
省掉几个……
[cpp]view plaincopy
- #elifdefinedSYSCLK_FREQ_72MHz
- /**
- *@briefSetsSystemclockfrequencyto72MHzandconfigureHCLK,PCLK2
- *andPCLK1prescalers.
- *@noteThisfunctionshouldbeusedonlyafterreset.
- *@paramNone
- *@retvalNone
- */
- staticvoidSetSysClockTo72(void)
- {
- …….
- }
这样结构就很清楚了。