Kopia av timers.c File Reference


Detailed Description

Timer Utilities implementation
Author:
Jörgen Birkler (birkler@yahoo.com)

Data Structures

Defines

Typedefs

Functions

Variables


Define Documentation

#define TIMER2_REQUESTED_PRESCALER
 

Prescaler requested by user.

TIMER2_CLOCK_FREQ is set to the external crystal frequency in Hz, Usually 32768Hz.

TIMER2_RTC_UPDATE_TIME should be set to the time between updates to the RTC (Real Time Clock). Usually 1000 ms.

When using a crystal to clock the core the chip waits 35ms for the clock to stabilize before any code is executed. The 35ms is default but can be changed to 1ms if using a ceramic resonator by changing a fuse bit. See the application note AN1259 about the RTC clock.

Larger updates times give lower power consumption but less accurate timers. Lower values gives more accurate timers but higher power consumption.

Accuracy of the RTC is only affected by the accuracy of the crystal not by the selected TIMER2_RTC_UPDATE_TIME. The resolution of the RTC is TIMER2_RTC_UPDATE_TIME/256.

PRECISION/RESOLUTION/ACCURACY

#define TIMER_RESET
 

Timer is expired.

#define TIMER_NO_UPDATE
 

Update all did not want any timers.


Typedef Documentation

typedef uint32_t LongMilliseconds_t
 

Special type used by update function.


Function Documentation

void Timers_Update void   )  [static]
 

Update the timers

  1. Calculate ticks elapsed since last update
  2. Calculate ms elapsed since last update
  3. Update all timers and get ms until next update
  4. Calculate ticks until next update
  5. Enable interrupt

void Timers_TriggerInterrupt void   )  [static]
 

Triggers an interrupt so that timers are updated

Milliseconds_t Timers_DecreaseAll const Milliseconds_t  delta  )  [static]
 

Decreases all timers with delta ms

Parameters:
delta milliseconds elapsed
Returns:
Milliseconds until next update or TIMER_NO_UPDATE if not timers are running.

INTERRUPT SIG_OUTPUT_COMPARE2   ) 
 

The output match compare interrupt.

INTERRUPT SIG_OVERFLOW2   ) 
 

Timer2 overflow interrupt.


Variable Documentation

volatile Timer_t Timers[TIMER_LAST] [static]
 

All the timers.


Copyright 2002 Jörgen Birkler. For accelR8 Accelerometer on Mon Jan 19 21:43:19 2004 by Doxygen 1.3.5.