#include "timer.h"
#include "MC9S08GB60.h"



unsigned int sys_time_s;
unsigned int sys_time_ms;

void tim_init(void) 
{

	 TPM1SC = 0x4F; 

    // timer value
    TPM1MODH = 0x01; 
    TPM1MODL = 0xF4;
    TPM1SC = 0x6C;
 
  
  	sys_time_s = 0;
  	sys_time_ms = 0;
  
} // tim_init

interrupt void IRQTimer1(void) {
//  TPM1SC;
  TPM1SC_TOF = 0; 
  TPM1SC_TOIE = 1;             // timer interupt on overflow enabled
  TPM1CNT = 0x00;              //vynulovanie casovaca
  
  sys_time_ms++;
  if(sys_time_ms >= 1000){
   			 sys_time_s ++;
   			 sys_time_ms = 0;
  }  
} 
