关于系统时钟的配置,以stm32f429为例,确认系统时钟SYSCLK
打开stm32f4xx.h 找到如下代码
#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F411xE)
#if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)25000000)
#endif
#elif defined(STM32F446xx)
#if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)8000000)
#endif
#endif
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint16_t)0x05000)
#endif
#if !defined (HSI_VALUE)
#define HSI_VALUE ((uint32_t)16000000)
#endif
因为我们使用的是f429 ,确认HSE_VALUE 为25000000。 之后打开system_f4xx.c找到以下代码。
#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx)
#define PLL_M 25
#elif defined (STM32F446xx)
#define PLL_M 8
#elif defined (STM32F411xE)
#if defined(USE_HSE_BYPASS)
#define PLL_M 8
#else
#define PLL_M 16
#endif
#endif
#define PLL_Q 7
#if defined(STM32F446xx)
#define PLL_R 7
#endif
#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
#define PLL_N 360
#define PLL_P 2
#endif
#if defined(STM32F401xx)
#define PLL_N 336
#define PLL_P 4
#endif
#if defined(STM32F411xE)
#define PLL_N 400
#define PLL_P 4
#endif
找到PLL_M PLL_N PLL_P 分别为25 360 2。
下面进行计算
PLL_VCO =(HSE_VALUE/PLL_M)* PLL_N=25/ 25* 360= 360MHz
SYSCLK = PLL_VCO / PLL_P = 360 / 2 = 180MHz
|