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 */

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