Exemple #1
0
/* Initialize the timer module. */
void TMR_Init(void)
{
  
  TmrInit();
  TmrEnable(gTmrNumber_d);  /*enable timer*/
  TMR_SetReg(gTmrNumber_d);
  /*Create the timer task */
  mTimerTaskID = TS_CreateTask(gTsTimerTaskPriority_c, TMR_Task);
  /* Count to maximum (0xffff - 2*4ms(in ticks)), to be sure that the currentTimeInTicks 
  will never roll over previousTimeInTicks in the TMR_Task() */
  mMaxToCountDown_c = 0xFFFF - TmrTicksFromMilliseconds(8); 
  /* The TMR_Task()event will not be issued faster than 4ms*/
  mTicksFor4ms = TmrTicksFromMilliseconds(4);
  
}
void TMR_Init(void)
{
  TmrInit();  

  TmrDisable( gTmr0_c );
  TmrDisable( gTmr1_c );
  TmrDisable( gTmr3_c );  
  TmrEnable(  gTmr2_c );
  
// TMR2 ==> 62,50 ms; prescaler = 32
  TMR2_CTRL = 0x1A20;  
  TMR2_SCTRL = 0x0000; 
  TMR2_LOAD = 0x0000;  
  TMR2_COMP1 =  46875; 
  TMR2_CSCTRL =0x0040;  
}