新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > SystemInit()函數(shù)的結(jié)構(gòu)分析

SystemInit()函數(shù)的結(jié)構(gòu)分析

作者: 時間:2016-11-23 來源:網(wǎng)絡(luò) 收藏
系統(tǒng)函數(shù)調(diào)用順序startup_stm32f10x_cl.s→ SystemInit() → SetSysClock()→ SetSysClockTo72()

總結(jié):開始是在keil4里看代碼,很混亂,后來把他粘到Notepad編輯器,一點擊就可以看出這個子函數(shù)到哪結(jié)束

本文引用地址:http://m.butianyuan.cn/article/201611/320445.htm

[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 變量是為了方便取出幾種情況下系統(tǒng)時鐘的實際值,例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. }
這樣結(jié)構(gòu)就很明晰了。


評論


技術(shù)專區(qū)

關(guān)閉