From 7581c0038dbf19da87a159e48bf7b114d3f42bf6 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Tue, 25 Jul 2017 20:15:12 +0200 Subject: [PATCH] stm32: correct some clock settings --- arduino_stm32f411.h | 13 +++++++++---- cmsis-system_stm32f4xx.c | 4 +++- cmsis-system_stm32f4xx.h | 4 ---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/arduino_stm32f411.h b/arduino_stm32f411.h index c4fd190..6b1bae0 100644 --- a/arduino_stm32f411.h +++ b/arduino_stm32f411.h @@ -24,8 +24,8 @@ */ #define RX_UART1 PA_10 #define TX_UART1 PA_9 -#define RX_UART2 PA_3 -#define TX_UART2 PA_2 +#define RX_UART2 PA_3 +#define TX_UART2 PA_2 #define RX_UART6 PA_12 #define TX_UART6 PA_11 @@ -33,8 +33,13 @@ */ #define F_CPU __SYSTEM_CLOCK -#define PPRE1_DIV (RCC_CFGR_PPRE1_DIV2) // 0x1000 -#define PPRE2_DIV (RCC_CFGR_PPRE2_DIV1) // 0x0000 +#if defined STM32F411xE + #define PPRE1_DIV (RCC_CFGR_PPRE1_DIV2) + #define PPRE2_DIV (RCC_CFGR_PPRE2_DIV1) +#elif defined STM32F446xx + #define PPRE1_DIV (RCC_CFGR_PPRE1_DIV4) + #define PPRE2_DIV (RCC_CFGR_PPRE2_DIV2) +#endif #if PPRE1_DIV > 0 #define APB1_DIV (1 << ((PPRE1_DIV >> 10) - 3)) diff --git a/cmsis-system_stm32f4xx.c b/cmsis-system_stm32f4xx.c index ad14fc1..f3a02ae 100644 --- a/cmsis-system_stm32f4xx.c +++ b/cmsis-system_stm32f4xx.c @@ -325,7 +325,7 @@ void SetSysClock(void) #define LATENCY FLASH_ACR_LATENCY_2WS #elif __SYSTEM_CLOCK == 180000000 #if !defined(STM32F446xx) - #warning You are running the controller out of specification! 180 MHz! + #error You are running the controller out of specification! 180 MHz! #endif #define PLLM 4 #define PLLN 180 @@ -371,6 +371,8 @@ void SetSysClock(void) RCC->CFGR &= ~(RCC_CFGR_PPRE1 | RCC_CFGR_PPRE2); RCC->CFGR |= PPRE1_DIV | PPRE2_DIV; + + RCC->DCKCFGR |= RCC_DCKCFGR_TIMPRE; } /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/cmsis-system_stm32f4xx.h b/cmsis-system_stm32f4xx.h index 7ce78f8..3ca356a 100644 --- a/cmsis-system_stm32f4xx.h +++ b/cmsis-system_stm32f4xx.h @@ -55,10 +55,6 @@ extern "C" { #endif -// #define __SYSTEM_CLOCK 96000000 -// #define __SYSTEM_CLOCK 100000000 -// #define __SYSTEM_CLOCK 108000000 // Overclocking is not recommended! - /* This variable is updated in by calling CMSIS function SystemCoreClockUpdate() */