Mode 2 (8-bit timer with auto- reload), Figure 92), Figure 93 gi – Rainbow Electronics AT89C5122 User Manual

Page 149

Advertising
background image

149

AT8xC5122/23

4202E–SCR–06/06

Figure 92. Timer/Counter x (x = 0 or 1) in Mode 1

Figure 93. Mode 1 Overflow Period Formula

Mode 2 (8-bit Timer with Auto-
Reload)

Mode 2 configures Timer 0 as an 8-bit Timer (TL0 register) that automatically reloads
from the TH0 register (see Figure 94). TL0 overflow sets the TF0 flag in the TCON reg-
ister and reloads TL0 with the contents of TH0, which is preset by the software. When
the interrupt request is serviced, the hardware clears TF0. The reload leaves TH0
unchanged. The next reload value may be changed at any time by writing it to the TH0
register.

Figure 95 gives the autoreload period calculation formula when in timer mode.

Figure 94. Timer/Counter x (x = 0 or 1) in Mode 2

Figure 95. Mode 2 Autoreload Period Formula

TRx

TCON reg

TFx

TCON reg

0

1

GATEx

TMOD reg

Overflow

Timer x
Interrupt
Request

C/Tx#

TMOD reg

TLx

(8 bits)

THx

(8 bits)

INTx#

Tx

FCK_Tx

/6

6

(65536 – (THx, TLx))

TFx

PER

=

F

CK_Tx

TRx

TCON reg

TFx

TCON reg

0

1

GATEx

TMOD reg

Overflow

Timer x
Interrupt
Request

C/Tx#

TMOD reg

TLx

(8 bits)

THx

(8 bits)

INTx#

Tx

FCK_Tx

/6

TFx

PER

=

F

CK_Tx

6

(256 – THx)

Advertising