單片機型號:STM32F091RCT6
低於PlatformIO開發平臺,如果更改外部晶振頻率,需修正stm32f0xx_hal_conf.h文件,原先使用keil開發時,此文件和項目相關,可以單獨修改,但是在PlatformIO平臺上,則此文件的路徑如下:
自己多次嘗試屏蔽此文件,包括刪除,都沒有成功,實在沒有方法,只能在此文件中,直接更改,代碼如下:
/* ######################### Oscillator Values adaptation ################### */
/**
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE 12000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
原先默認頻率爲8M,現在改爲12M。
但是這種方法要求,所有的F0項目,均使用同一頻率晶振,不能個性化設置。
也或許時對PlatformIO理解不深,此問題暫時保留,待項目深入後,看是否有更好的解決方法。