/*************************************************************************** 
ISR for rtos_ex2
Timer 0 interrupt is high priority source.
Reloads Timer, and calls OSTimer()
TJW 30.12.05
****************************************************************************/

#include <salvo.h>
#include <p18F242.h>
#include <timers.h>

//function prototype(s)
void timer0_isr (void);

static unsigned int tick_counter = 0;

//Define the high priority interrupt vector to be at 0008h
#pragma code high_vector=0x08
void interrupt (void)
{
  _asm GOTO timer0_isr _endasm  //jump to ISR
}

#pragma code	//Return to default code section

//Function timer0_isr specified as high-priority ISR

#pragma interrupt timer0_isr 

//timer0_isr function.
void timer0_isr (void)
{
	WriteTimer0 (64918);	//Timer reload value gives 625 cycles to overflow, 	
 								//less compensation for interrupt latency
 	OSTimer();
	tick_counter++;			//increment tick counter, (for simulation)
  	INTCONbits.TMR0IF = 0; //Clear TMR0 interrupt flag 
}

