timer.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define T2_TICKS_TO_MSEC   642
 Number of Timer2 ticks in a millisecond. More...
 
#define T2_PERIOD   20
 Timer2 Period in ms. More...
 

Functions

void initTimer2 (void)
 Initializes Timer2. More...
 
void initTimer4 (void)
 Initializes Timer4. More...
 
long unsigned int getTime ()
 Get current time in ms. More...
 

Macro Definition Documentation

#define T2_PERIOD   20

Timer2 Period in ms.

When the period is reached, the timer is reset. Since Timer2 is used in the output compare (PWM output), this period defines the period of the PWM as well. If you want 50Hz, set this as 20ms

Definition at line 27 of file timer.h.

#define T2_TICKS_TO_MSEC   642

Number of Timer2 ticks in a millisecond.

To calculate this, take: 1/(frequencyCPU/Timer2PreScaler)*TICKS_TO_MSEC should equal close to 0.001 or 1 ms In this case, (1/(41Mhz/64))*642 == ~1ms

This value is used to accurately define the timer2 period (used for output pwm frequency

Definition at line 20 of file timer.h.

Function Documentation

long unsigned int getTime ( )

Get current time in ms.

Returns
ms

Definition at line 54 of file timer.c.

Here is the caller graph for this function:

void initTimer2 ( void  )

Initializes Timer2.

Its used as a 16-bit timer. Used for PWM input and output management

Its used as a 16-bit timer

Definition at line 16 of file timer.c.

Here is the caller graph for this function:

void initTimer4 ( void  )

Initializes Timer4.

Used as a 16-bit, interrupt enabled, 1ms timer

Initializes Timer4.

Definition at line 33 of file timer.c.

Here is the caller graph for this function: