| OSRegisterTimer | Function (ROM Call 0xF0)

system.h

short OSRegisterTimer (short timer_no, unsigned long T);

Registers a notify (countdown) timer.

TIOS has several notify (countdown) timers. The number of timers is not the same on all AMS versions:

All AMS versions up to 2.03 | 6 timers (1 to 6)
AMS 2.04 and 2.05 | 7 timers (1 to 7)
AMS 2.07, 2.08 and 2.09 | 8 timers (1 to 8)

OSRegisterTimer initializes the timer which ID number is timer_no, and sets its initial value to T. Every time the Auto-Int 5 is triggered (approximatively 20 times per second if you didn't change the programable rate generator), the current value of the timer is decremented by 1. When the current value reaches zero, nothing special happens, but a flag is set which indicates that the timer is expired. This flag may be check using function OSTimerExpired.
OSRegisterTimer returns timer_no if the registration was successful, else returns zero. This happens if you give wrong parameters, or if the timer timer_no is already in use. So, you must first free the timer using OSFreeTimer.
Usual use of the timers:

- Timer 1 seems to be free for use on all AMS versions.
- Timer 2 is used for automatic power-down (APD) counting, so this is an official method to change APD rate to, for example, 100 seconds:

      OSFreeTimer (APD_TIMER);
       OSRegisterTimer (APD_TIMER, 100*20);

- Timer 3 is used for link communication.
- Timer 4 is used for cursor blinking.
- Timer 5 is sometimes used for measuring time in some TI-Basic functions like CyclePic.
- Timer 6 seems to be free for use on all AMS versions.
- Timer 7 is used on AMS 2.04 and above by the standard AUTO_INT_5 routine to launch battery level checking routine every 20 ticks. You shouldn't use it...
- Timer 8 is used on AMS 2.07 and above in particular by the functions related to TI-Navigator.

Legal timer numbers (like APD_TIMER) are defined in enum Timers, to make a program more readable. See also other timer functions for more info.

Used by: cmd_cyclepic, cmd_sendcalc, cmd_sendchat, BatTooLowFlash, LIO_RecvData, GT_Trace, Regraph

See also: FiftyMsecTick, OSFreeTimer, OSTimerCurVal, OSTimerExpired, OSTimerRestart