/* =========================================================================== */
/* Project:        timer */
/* File:           timerInt.c */
/* Organization:    */
/* Author:           (initial version generated by RBuilder) */
/* Date:           12/7/2004 */
/* =========================================================================== */

#include "ST7lib_config.h"
/* --------------------------------------------------------------------------- */
/* Function:       TIMERA_IT_Routine(void) */
/* Purpose:        Interrupt Subroutine for TIMERA Interrupt */
/* Date:           12/7/2004 */
/* --------------------------------------------------------------------------- */

//this is the counter which is incremented every 50ms
volatile unsigned long t_50ms=0;


//the reset value of the timer's counter
unsigned int Tmp=0x8000;


#ifdef _HIWARE_                                  /* Test for HIWARE Compiler */
#pragma TRAP_PROC SAVE_REGS            /* Additional registers will be saved */
#else
#ifdef _COSMIC_                                  /* Test for Cosmic Compiler */
@interrupt                                      /* Cosmic interrupt handling */
#else
#ifdef _RAISONANCE_                                  /* Test for Raisonance Compiler */
//nothing                                     
#else
#error"Unsupported Compiler!"                 /* Compiler Defines not found! */
#endif
#endif
#endif


void TIMERA_IT_Routine(void) interrupt 8
{
#ifdef _RAISONANCE_  
// interrupt 8                                   
#endif
	// Interrupt generated by OCF1
	if(TIMERA_Status_Flag(TIMER_FLAG_OCF1)==TRUE)  
	{
		//this offset makes a 10ms tick with a 12MHz ext. clock  
		// like the one from RLink
		Tmp += 37500; 
		
		//refresh timer for next tick
		TIMERA_OCMP_Mode(TIMER_OCMP_1,Tmp,TIMER_OUTPUT_F);
		TIMERA_Clear_Flag(TIMER_FLAG_OCF1);
		
		//increment the counter of 50-ms ticks
	   t_50ms++;
	}
	
	//clear OCF2
	TIMERA_Clear_Flag(TIMER_FLAG_OCF2);
}/* end of TIMERA_IT_Routine(void) */



