System Clock :: Waddon

From Grahamsoft Labs

Jump to: navigation, search

An interrupt is created by the built in timerX roughly 30 times a seconds. On each interrupt a function is called that increments a integer.

The timer should be set up as follows:

OpenTimer2( TIMER_INT_OFF &
            T2_PS_1_1     &
            T2_POST_1_8   );

And example C code for timer handling is:

#include <timers.h>

#pragma interrupt Increment_Timer
void Increment_Timer( void )
{
 if ( Half_Second == 72000 )	//Hour achived
 {
    Half_Second = 0;
 }
 else
 {
    Half_Second++;
 }
}
Bridport Technologies