From ab5b2c61e6925b03a69bc9ac7f9b9013737d3c29 Mon Sep 17 00:00:00 2001 From: fruchti Date: Sat, 26 Dec 2020 11:45:20 +0100 Subject: [PATCH] Add clock frequency definitions --- stm32f103c8t6/src/clock.h | 6 ++++++ stm32f103c8t6/src/main.c | 4 ++++ stm32f103c8t6/src/main.h | 1 + 3 files changed, 11 insertions(+) create mode 100644 stm32f103c8t6/src/clock.h diff --git a/stm32f103c8t6/src/clock.h b/stm32f103c8t6/src/clock.h new file mode 100644 index 0000000..80e3cb9 --- /dev/null +++ b/stm32f103c8t6/src/clock.h @@ -0,0 +1,6 @@ +#pragma once + +#define CLOCK_APB1 36000000 +#define CLOCK_APB2 72000000 +#define CLOCK_SYSCLK 72000000 +#define CLOCK_AHB 72000000 diff --git a/stm32f103c8t6/src/main.c b/stm32f103c8t6/src/main.c index a79f57f..29b159b 100644 --- a/stm32f103c8t6/src/main.c +++ b/stm32f103c8t6/src/main.c @@ -24,6 +24,10 @@ static void Clock_Init(void) // Resulting clocks: // SYSCLK, AHB, APB2 72 Mhz // APB1, ADC 36 MHz +#if (CLOCK_SYSCLK != 72000000) || (CLOCK_AHB != 72000000) \ + || (CLOCK_APB1 != 36000000) || (CLOCK_APB2 != 72000000) +#error Clock initialisation does not match definitions in clock.h. +#endif // Disable all interrupts RCC->CIR = 0x00000000; diff --git a/stm32f103c8t6/src/main.h b/stm32f103c8t6/src/main.h index 82ce17b..ee37535 100644 --- a/stm32f103c8t6/src/main.h +++ b/stm32f103c8t6/src/main.h @@ -2,6 +2,7 @@ #include #include "stm32f1xx.h" +#include "clock.h" #include "pinning.h" #include "buildid.h" #include "debug.h"