Timer - Nintendo DMG-01 - Game Boy Console Manual

Manual
Table of Contents

Advertisement

2.10. Timer

2.10. Timer
Sometimes it's useful to have a timer that interrupts
at regular intervals for routines that require
periodic or percise updates. The timer in the GameBoy
has a selectable frequency of 4096, 16384, 65536, or
262144 Hertz. This frequency increments the Timer
Counter (TIMA). When it overflows, it generates an
interrupt. It is then loaded with the contents of
Timer Modulo (TMA). The following are examples:
;This interval timer interrupts 4096 times per second
ld
a,-1
ld
($FF06),a
ld
a,4
ld
($FF07),a
;This interval timer interrupts 65536 times per second
ld
a,-4
ld
($FF06),a
ld
a,5
ld
($FF07),a
Page 30
;Set TMA to divide clock by 1
;Set clock to 4096 Hertz
;Set TMA to divide clock by 4
;Set clock to 262144 Hertz
TM
Game Boy
CPU Manual
V 1.01

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Game boy

Table of Contents