From 19a78f2527030d20b1ff4a82826beb6139e2e005 Mon Sep 17 00:00:00 2001 From: fruchti Date: Thu, 16 Jul 2020 16:17:35 +0200 Subject: [PATCH] Use default 8 MHz clock, disable PLL Reducing the frequency to one sixth increases flickering somewhat, but it's not too bad. More importantly, the current draw (at 5 V) at the lowest brightness settings (all LEDs white) is reduced from 13 mA to about 3 mA. --- build-number.txt | 2 +- src/light_sensor.c | 2 +- src/system.c | 14 -------------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/build-number.txt b/build-number.txt index 209ac45..ea80947 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -287 +288 diff --git a/src/light_sensor.c b/src/light_sensor.c index 3f1c9af..6f0d8e1 100644 --- a/src/light_sensor.c +++ b/src/light_sensor.c @@ -49,7 +49,7 @@ void LightSensor_Init(void) TIM14->CCMR1 = TIM_CCMR1_CC1S_0; TIM14->CCER = TIM_CCER_CC1E | TIM_CCER_CC1P; // Set up TIM14 for an oveflow interrupt at the configured interval - TIM14->PSC = 48000 * LIGHTSENSOR_INTERVAL / 65535; + TIM14->PSC = 8000 * LIGHTSENSOR_INTERVAL / 65535; TIM14->ARR = 65535; TIM14->DIER = TIM_DIER_UIE; NVIC_EnableIRQ(TIM14_IRQn); diff --git a/src/system.c b/src/system.c index a7b33de..7ca3df8 100644 --- a/src/system.c +++ b/src/system.c @@ -3,20 +3,6 @@ void SystemInit(void) { - // Activate HSI and wait for it to be ready - RCC->CR = RCC_CR_HSION; - while(!(RCC->CR & RCC_CR_HSIRDY)); - - // Set PLL to x12 (-> 48MHz system clock) - RCC->CFGR = RCC_CFGR_PLLMUL_3 | RCC_CFGR_PLLMUL_1; - - // Activate PLL and wait - RCC->CR |= RCC_CR_PLLON; - while(!(RCC->CR & RCC_CR_PLLRDY)); - - // Select PLL as clock source - RCC->CFGR = RCC_CFGR_PLLMUL_3 | RCC_CFGR_PLLMUL_1 | RCC_CFGR_SW_1; - // Disable all interrupts RCC->CIR = 0x00000000; }