Skip to content

Commit

Permalink
Fixed an issue where the timer load value was not being calculated co…
Browse files Browse the repository at this point in the history
…rrectly, causing the timer to have an incorrect period (roughly half of what it should be).
  • Loading branch information
jackerzhaques committed Jun 23, 2019
1 parent 6eaab16 commit 0fcc5f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions TaskScheduler/TaskScheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions TaskScheduler/TaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <stdbool.h>

//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;
Expand Down

0 comments on commit 0fcc5f7

Please sign in to comment.