From e05a43a74f693c56d1015a1675cae06363cdbb8b Mon Sep 17 00:00:00 2001 From: polymurph Date: Mon, 20 Dec 2021 13:30:50 +0100 Subject: [PATCH] transfered imer example code from main.c to .cpp --- main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index dcd74ba..9646118 100644 --- a/main.cpp +++ b/main.cpp @@ -6,6 +6,7 @@ #include "deviceSetup.h" #include "usart.h" #include "ascii.h" +#include "timer.h" int main(int argc, char *argv[]) { @@ -14,6 +15,12 @@ int main(int argc, char *argv[]) delayInitMs(8000000, 1000); + timerActivateBus(timer_2); + timerSetPrescaler(timer_2, 1599); + timerSetAutoReload(timer_2, 9999); + timerClearCounter(timer_2); + timerEnableTimer(timer_2); + pinConfig(pinB3, output, pushPull, def_res, def_speed); pinConfig(pinA0, input, def_stage, pullDown, def_speed); @@ -40,7 +47,15 @@ int main(int argc, char *argv[]) } pinWrite(pinB3,0); + + while(1) + { + while(!(TIM2->SR & 1)); + TIM2->SR &= ~1; + pinToggle(pinB3); + } + /* while(1) { //USART will rteturn what wou type and trun led on if you press "1" @@ -51,10 +66,11 @@ int main(int argc, char *argv[]) pinWrite(pinB3,1); } else if(a == '0'){ pinWrite(pinB3,0); - } delayMs(100); } + */ + return 1; }