/******************************************************************************** * MAHE, 13.05.2002, 12H40 - now compiling as project of separated source files ********************************************************************************/ #ifndef _TIMER_H #define _TIMER_H /*************************************************************** * Struct for global timer * timer1Counter is incremented every overflow of timer1 in ISR, if * timer1Counter>N, it is set to 0 * counter is decremented every N ticks of timer1Counter, * Timer1 is incrementing from 0x0000 to 0xFFFF every instruction * cycle by setting the prescaler to 1:1. At f=4MHz ext clock, * -> T=0,25µs*4=1µs seconds. * 50000=0x3CAF * N=0,1s/deltaT, deltaT=50000*T=50000*1µs=50000µs=0,05s * N=2 * isTerminated==1 -> timer terminated * !isTerminated && !isRunning -> timer is not active * !isTerminated && isRunning -> timer is running ***************************************************************/ struct stru_timer { unsigned int timer1Counter; unsigned int counter; char isTerminated; char isRunning; unsigned int N; }; typedef struct stru_timer Timer; #define TMR1_MSB_RELOAD 0x3C #define TMR1_LSB_RELOAD 0xAF #define GLOBAL_TIMER_N 2 void initTimer1(void); void startTimer1(void); void stopTimer1(void); void startGlobalTimer(unsigned int); char isFinishedGlobalTimer(void); #endif /* of _TIMER_H */