> quicklinks

ti-92

ti-89
linux
how-to's
about us
links
projects
members
archive

quick links


ontic

tie
ultrapascal
 

o









   

> how-to's > using of the timer

>> how to use the timer in own programs

To use the timer, you first have to set a defined frequency (You don't know the current frequency). I suggest - you have - to set the frequency to $d1 - 30 Hz (30 ticks per second), use port $600016. Now you can use the AutoInt 5 with a counter. There you should use an internal counter, and when this counter is 30, then a second is over. It sounds difficult, but look at the code, it is easy...

;********* VARIABLES
oldTimer       dc.l 0
Time           dc.w 0         ; Your time!
InternCounter  dc.w 0         ; Internal counter
; InstallTimer
; Installs your timer interrupt and sets the right frequency.
InstallTimer:
   move.l  $64+(5-1)*4,oldTimer
   clr.w   InternCounter
   move.l  #TimerInterrupt,$64+(5-1)*4    ; Timer installed!
   move.w  #$d1,($600016)                 ; Set frequency
   rts

; DeinstallTimer
; Removes your timer interrupt, you should call this routine at the end!
DeinstallTimer:
   move.l  oldTimer,$64+(5-1)*4
   rts

TimerInterrupt:
   add.w   #1,InternCounter
   cmp.w   #29,InternCounter              ; Since we start with 0
   beq     ResetInternCounter
   rte
ResetInternCounter:
   ; +1 or -1 of the time
   sub.w   #1,Time
   ;add.w   #1,Time
   clr.w   InternCounter
   rte


So, this was, how you can use the timer.

 

powered by ticalc.org, levante.de, xoom.com, listbot.com, fastcounter.com
last update on 12.12.1999