Hi
The following can be used to initialise the PIT to generate a periodic interrupt in the range from 2.5ms to 40ms on the NE64 (25MHz clock)
#define TICK_RESOLUTION 5 // 5ms rate setting
#define OSCCLK 25000000
// Routine to initialise the Real Time Tick interrupt
//
#define REQUIRED_MS ((1000/TICK_RESOLUTION)) // The TICK frequency we require in kHz
#define TICK_DIVIDE (OSCCLK/REQUIRED_MS) // the divide ration required
#define REGISTER_VALUE (((TICK_DIVIDE + 65536/2)/65536) - 1) // we assume 2^16 prescaler to give range 2.5...40ms
extern void fnStartTick(void)
{
RTICTL = (0x70 + REGISTER_VALUE); // set the prescaler to generate the periodic tick
CRGFLG = RTIF; // Reset interrupt request flag
CRGINT = RTIE; // Enable interrupt
}
/**************************** Real Time Clock interrupt ******************************************/
__interrupt void RealTimeInterrupt(void)
{
CRGFLG = RTIF; // Reset interrupt request flag
// do other stuff her every 5ms.....
}
Regards
Mark
www.uTasker.com