单片机型号: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理解不深,此问题暂时保留,待项目深入后,看是否有更好的解决方法。