From WikiTI
Revision as of 09:23, 17 September 2011 by Runer112 (Talk | contribs)

Jump to: navigation, search
This port only exists as a distinct port on the TI-83 Plus Silver Edition, the TI-84 Plus, and the TI-84 Plus Silver Edition. On the standard TI-83 Plus, it acts as a shadow of port 10.


Port Number: 30 - 38

Function: Timers On the 83+SE and 84+(SE) there are 3 timers that are independent of each other and each timer is controlled by 3 ports, On/off, Loop control, and the counter itself. They can be used for accurate delay waiting, interrupts that execute at almost any desired frequency, or for just keeping time.

On/Off Loop Control Counter
Timer1 30 31 32
Timer2 33 34 35
Timer3 36 37 38

On/Off ports:

The On/Off ports are 30, 33, and 36. These ports control what clock is used for this timer and a divisor(needed since the counter is only 8bit). The upper two bits(6 & 7) tell what clock is being used. 00 if none and the timer is off, 01 for the crystal timer, and 02 for the CPU clock. 03 would suggest a combination of the CPU clock and the crystal timers, but I highly doubt it. Bits 0-5 of the On/Off ports control the divisor. For simplicity, here is a table with the output values next to the the frequencies that would be generated.

Value Frequency
00h OFF
~ ~
40h 10922.667 Hz (32768/3)
41h 992.9697 Hz (32768/33)
42h 99.902 Hz (32768/328)
43h 9.9993 Hz (32768/3277)
44h 32768 Hz
45h 2048 Hz
46h 128 Hz
47h 8 Hz
~ ~
80h CPU clock speed
81h CPU clock / 2
82h CPU clock / 4
84h CPU clock / 8
88h CPU clock / 16
90h CPU clock / 32
A0h CPU clock / 64

Since Silver Edition calculators CPU speed can be adjusted the timers will run at whatever the current CPU speed is(if selected of course).

Loop Control ports:

The Loop Control ports are 31, 34, and 37.

When bit 0 is set on this port it causes the timer to loop when the counter hits 0. Once it does, the counter will start back at the value you initially placed in it. To keep it looping from that value, you must output to the loop control port at every loop. If you miss one bit 2 of this port will be set, and the counter will carry to FF continue to count down.

When bit 1 is set this timer will generate an interrupt when the counter hits 0. The interrupt must acknowledge or it will recurse upon EI. Acknowledge it by writing to the Loop control port. Depending on whether you have looping enabled or not, you can start the timer again by write to the counter port.

At this point I want to stress that you must acknowledge the timers whenever the counter reaches zero. Every time the counter hits zero the appropriate bit is set in port 04h. To reset those bits you MUST write to the loop control port, whether you have interrupts enabled or not.

Counter ports:

The Counter ports are 32, 35, and 38.

Once the prior 2 ports have been setup all that is need to activate the timer is to send the desired value you wish to count down from to the counter port. However if you send 0 it will loop no matter what and it will not affect port 4, so keep it above 0.

Also note that you should turn off the timer when you are done, do this by writing 0 to the on/off port and loop control.


For some reasons the timers do not seem to generate interrupts if the CPU is halt. I can only imagine that this is either a bug in the hardware or that there is more information missing. In any case, if you intend to use the crystal timers to generate an interrupt leave the normal timers on so that you can escape any halt.

The TI-84 uses the timers for its own purposes, leaving only timer 1 free. A set of undocumented bcalls can be used to manipulate it. Whether or not you use those calls, TI-OS's interrupt checks the status of each of the timers and will disable interrupts from them and set them to loop. (See code at 0E11h)

Example Code

 ;Setup up a timer that waits 2 seconds
   ld a,$47      ;8 hz
   out ($30),a
   ld a,0        ; no loop, no interrupt
   out ($31),a
   ld a,16       ;16 ticks / 8 hz equals 2 seconds
   out ($32),a
   in a,(4)
   bit 5,a       ;bit 5 tells if timer 1
   jr z,wait     ;is done
   xor a
   out ($30),a   ;Turn off the timer.
   out ($31),a

Credits and Contributions

  • Michael Vincent: Documentation found here.
  • James Montelongo: Documentation found here.