From ee7d7e31edf5b8e106dc757889bb308af9621e1c Mon Sep 17 00:00:00 2001 From: polymurph Date: Tue, 21 Dec 2021 12:08:58 +0100 Subject: [PATCH] working timer blinki example --- bsl/csl/stm32f042/Src/timer.c | 3 ++- main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bsl/csl/stm32f042/Src/timer.c b/bsl/csl/stm32f042/Src/timer.c index e033787..f467f91 100644 --- a/bsl/csl/stm32f042/Src/timer.c +++ b/bsl/csl/stm32f042/Src/timer.c @@ -16,7 +16,8 @@ void timerActivateBus(timerNo_t timer) void timerEnableTimer(timerNo_t timer) { - BASE->CR1 &= ~0x01; //all the timers have the same CEN bit in CR1 register pos 0 + //BASE->CR1 &= ~0x01; //all the timers have the same CEN bit in CR1 register pos 0 + BASE->CR1 |= 0x01; //all the timers have the same CEN bit in CR1 register pos 0 } void timerSetClkSource(timerNo_t timer, clkSources_t clk) diff --git a/main.cpp b/main.cpp index 9646118..61553c2 100644 --- a/main.cpp +++ b/main.cpp @@ -16,8 +16,8 @@ int main(int argc, char *argv[]) delayInitMs(8000000, 1000); timerActivateBus(timer_2); - timerSetPrescaler(timer_2, 1599); - timerSetAutoReload(timer_2, 9999); + timerSetPrescaler(timer_2, 159); + timerSetAutoReload(timer_2, 999); timerClearCounter(timer_2); timerEnableTimer(timer_2);