Overview | Main | State Machine | Events | IR | Tape | Drivetrain | PWM | Flash | Two Minute Timer | Bump
void startTimer(void): start the two-minute timer
              
              char getTimer(void): query the state of the two-minute timer
              
              void interrupt _Vec_tim2ch5 TimerSignalInterrupt(void):  two-minute timer implementation
              
              void main(void): test harness for two-minute timer 
The two-minute timer module provides a timer that can be started at any point in the code and will expire two minutes later. The module provides a start function and a query function.
PSEUDOCODE
(Download Pseudocode .doc 26kb)
void startTimer(void)
    Turn on timer 2 if it isn’t already
    Set pre-scale to the slowest, /128 or 187.5 kHz clock
    Set channel 5 to output compare
    Set first event for as long as possible from now
    Clear the interrupt flag
    Enable the local interrupt
char getTimer(void)
    Return the current state of the timer
void interrupt _Vec_tim2ch5 TimerSignalInterrupt(void)
    Set up the next compare
    Clear the flag for the compare
    Increment the count of how many times we’ve done this
    If the count is now the right amount for two minutes
        Change the state to expired
void main(void) **Test Harness**
    Start the timer
    Repeat forever
        Report the state of the timer
      
    

