Speeduino
Loading...
Searching...
No Matches
timers.h
Go to the documentation of this file.
1
2
3/*
4NOTE - This file and it's associated functions need a CLEARER NAME
5
6//Purpose
7We're implementing a lower frequency interrupt loop to perform calculations that are needed less often, some of which depend on time having passed (delta/time) to be meaningful.
8
9
10//Technical
11Timer2 is only 8bit so we are setting the prescaler to 128 to get the most out of it. This means that the counter increments every 0.008ms and the overflow at 256 will be after 2.048ms
12Max Period = (Prescale)*(1/Frequency)*(2^8)
13(See arduinomega.blogspot.com.au/2011/05/timer2-and-overflow-interrupt-lets-get.html)
14
15We're after a 1ms interval so we'll need 131 intervals to reach this ( 1ms / 0.008ms per tick = 125).
16Hence we will preload the timer with 131 cycles to leave 125 until overflow (1ms).
17
18*/
19#ifndef TIMERS_H
20#define TIMERS_H
21
22#include <stdint.h>
23
24uint8_t getAndClearTimerMask(void);
25void oneMSInterval(void);
26void initialiseTimers(void);
27
28#endif // TIMERS_H
uint8_t getAndClearTimerMask(void)
Definition timers.cpp:51
void initialiseTimers(void)
Definition timers.cpp:37
void oneMSInterval(void)
Definition timers.cpp:63