Timer Tick CFR API TimerGetTicks and TimerResetTicks


7526 Flash level 4.25 and higher and EPROM 3.12 and higher includes new CFR APIs which allows the CFR programmer to have access to a free-running, incrementing 5mS (millisecond) timer tick counter. The tick counter may be sampled or reset back to 0.

7526 CFR toolkit files (CFRAPI26.H, CFRAPI26.LIB) dated 5/30/97 are required to build CFRs with this function.

Example:


/* Returns E_INTERNAL if run on a 7526 with EPROM older than 3.12 (non-Enet)    */
/* or FLASH-ware older than B4.24.                                              */
/* (sprintf_752x is from the sample CFR26LIB.LIB library)                       */

   USHORT usTicker;

   
   ...


   /* 
    *  Use 7526's 5mS timer ticker to determine how long it has been since
    *  we last received a character on the auxillary serial port.
    *  If more than 200mS (40 ticks) then we have timed-out waiting for
    *  other device and we change our master/slave state.
    *  This is part of a routine which is called frequently to process incoming
    *  characters to our Serial 1 port.
    */


   usCRC = ComRead( 1, 100, combuffer, &count);


   if( usCRC == E_OK )
   {
     /* 
      *  Got some chars.  Reset ticks counter (assumes this is the only part of 
      *  the CFR which uses the counter, otherwise this would be rude... ).
      */
     TimerResetTicks();

     /*
      *  Process the incoming chars per protocol state machine 
      */

      ....


   }
   else
   {
     /* 
      *  Did not receive any new chars
      *  Sample timer -- if more than 40 than we've timed out waiting
      *  and we will change our slave/master state.
      */
          
     TimerGetTicks( &usTicker );

     if( usTicker > 40 )
     {
       /* Timed out -- change state */

        ..
     }

   }