STM32F105的串口亂碼問題

STM32F105的串口亂碼問題

我在調試STM32F105時,串口發送數據一致亂碼,找來找去,原來問題還是出現在軟件配置上。
然後我發現在文件stm32f10x.h中有這麼一段代碼。

if !defined HSE_VALUE

#ifdef STM32F10X_CL
#define HSE_VALUE ((uint32_t)25000000) /!< Value of the External oscillator in Hz /
#else
#define HSE_VALUE ((uint32_t)8000000) /!< Value of the External oscillator in Hz /
#endif /* STM32F10X_CL */

endif /* HSE_VALUE */

HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator
這個是官網默認外部晶振25MHZ
然而我使用的外部晶振爲8MHZ所以改成

ifdef STM32F10X_CL

#define HSE_VALUE ((uint32_t)8000000) /!< Value of the External oscillator in Hz /
#else
#define HSE_VALUE ((uint32_t)8000000) /!< Value of the External oscillator in Hz /
#endif /* STM32F10X_CL */

endif /* HSE_VALUE */

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章