STM32 标准库3.5修改默认外部8M晶振为16M晶振
【摘要】
ST官方标准库V3.5默认的外部晶振频率为8M,实际使用中外部晶振需要修改为16M;
经过实验,修改有效,具体的patch如下:
修改 HSE_VALUE 值
diff --git "a/Libra...
ST官方标准库V3.5默认的外部晶振频率为8M,实际使用中外部晶振需要修改为16M;
经过实验,修改有效,具体的patch如下:
修改 HSE_VALUE 值
diff --git "a/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h" "b/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h"
index 8bf7624..e0ad316 100644
--- "a/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h"
+++ "b/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/stm32f10x.h"
@@ -116,7 +116,9 @@
#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 */
+// #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
+#define HSE_VALUE ((uint32_t)16000000) /*!< Value of the External oscillator in Hz */
+
#endif /* STM32F10X_CL */
#endif /* HSE_VALUE */
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
修改 SetSysClockTo72 函数中RCC 配置
diff --git "a/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c" "b/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c"
index 71efc85..eb912bd 100644
--- "a/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c"
+++ "b/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c"
@@ -1053,7 +1054,11 @@ static void SetSysClockTo72(void)
/* PLL configuration: PLLCLK = HSE * 9 = 72 MHz */
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE |
RCC_CFGR_PLLMULL));
- RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL9);
+
+// RCC_CFGR_HPRE_DIV2
+ //RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL9 | RCC_CFGR_PPRE1_DIV2);
+ RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSE | RCC_CFGR_PLLMULL9 | RCC_CFGR_PLLXTPRE_HSE_Div2);
+
#endif /* STM32F10X_CL */
/* Enable PLL */
STM32F10X_CL */
/* Enable PLL */
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
文章来源: great.blog.csdn.net,作者:小麦大叔,版权归原作者所有,如需转载,请联系作者。
原文链接:great.blog.csdn.net/article/details/103740847
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)