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.
This commit is contained in:
fruchti 2020-07-16 16:17:35 +02:00
parent 8c3bc4222c
commit 19a78f2527
3 changed files with 2 additions and 16 deletions

View file

@ -1 +1 @@
287 288

View file

@ -49,7 +49,7 @@ void LightSensor_Init(void)
TIM14->CCMR1 = TIM_CCMR1_CC1S_0; TIM14->CCMR1 = TIM_CCMR1_CC1S_0;
TIM14->CCER = TIM_CCER_CC1E | TIM_CCER_CC1P; TIM14->CCER = TIM_CCER_CC1E | TIM_CCER_CC1P;
// Set up TIM14 for an oveflow interrupt at the configured interval // 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->ARR = 65535;
TIM14->DIER = TIM_DIER_UIE; TIM14->DIER = TIM_DIER_UIE;
NVIC_EnableIRQ(TIM14_IRQn); NVIC_EnableIRQ(TIM14_IRQn);

View file

@ -3,20 +3,6 @@
void SystemInit(void) 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 // Disable all interrupts
RCC->CIR = 0x00000000; RCC->CIR = 0x00000000;
} }