From 0fcc5f78b3a79ae50e655369bb8a7f37bd9fa02a Mon Sep 17 00:00:00 2001 From: toddmorehouse Date: Sat, 22 Jun 2019 21:46:00 -0400 Subject: [PATCH] Fixed an issue where the timer load value was not being calculated correctly, causing the timer to have an incorrect period (roughly half of what it should be). --- TaskScheduler/TaskScheduler.c | 4 ++-- TaskScheduler/TaskScheduler.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TaskScheduler/TaskScheduler.c b/TaskScheduler/TaskScheduler.c index 9698296..acce0d6 100644 --- a/TaskScheduler/TaskScheduler.c +++ b/TaskScheduler/TaskScheduler.c @@ -76,10 +76,10 @@ void InitializeTaskScheduler(uint32_t timerBase, uint32_t sysCtlTimerPeriph, uin //Configure the timer to be a periodic 100us timer TimerConfigure(timerBase, TIMER_CFG_PERIODIC); - TimerLoadSet(timerBase, TIMER_A, sysClkFreq * TASK_SCHEDULER_TIMER_PERIOD / 1000000); + TimerLoadSet(timerBase, TIMER_A, sysClkFreq * (TASK_SCHEDULER_TIMER_PERIOD / 1000000.0f)); //Configure the ISR - TimerIntRegister(timerBase, TIMER_BOTH, TaskSchedulerTimer_ISR); + TimerIntRegister(timerBase, TIMER_A, TaskSchedulerTimer_ISR); IntEnable(timerIntBase); TimerIntEnable(timerBase, TIMER_TIMA_TIMEOUT); diff --git a/TaskScheduler/TaskScheduler.h b/TaskScheduler/TaskScheduler.h index 189db52..b519e02 100644 --- a/TaskScheduler/TaskScheduler.h +++ b/TaskScheduler/TaskScheduler.h @@ -5,8 +5,8 @@ #include //For the most accurate timer, choose a frequency that is an integer -#define TASK_SCHEDULER_TIMER_PERIOD 100 //us -#define TASK_SCHEDULER_TICKS_IN_ONE_SECOND 1/TASK_SCHEDULER_TIMER_PERIOD * 1000000 +#define TASK_SCHEDULER_TIMER_PERIOD 100.0f //us +#define TASK_SCHEDULER_TICKS_IN_ONE_SECOND 1.0f/TASK_SCHEDULER_TIMER_PERIOD * 1000000.0f struct Task_tag; typedef struct Task_tag Task;