beautypg.com

9 sample applications, Chapter 7 timer/counter units – NEC PD78214 User Manual

Page 158

background image

129

Chapter 7 Timer/Counter Units

7

7.1.9 Sample Applications

(1) Interval timer operation (1)

By free running 16-bit timer 0 (TM0), and adding a value to a compare register (CR00, CR01) in an interrupt
handling routine, the 16-bit timer/counter can be used as an interval timer whose period is as long as the added
value. (See Fig. 7-24.)

This interval timer has a resolution of 1.3

µs, and can count up to 87.4 ms (at internal system clock f

CLK

= 6

MHz).

In addition, 16-bit timer 0 (TM0) has two compare registers, so that interval timers with two types of periods
can be produced.

Fig. 7-25 shows the setting of control registers. Fig. 7-26 shows the setting procedure. Fig. 7-27 shows
interrupt handling.

Fig. 7-24 Timing of Interval Timer Operation (1)

n

n

0H

TM0
count value

MOD(2n)

MOD(3n)

FFFFH

FFFFH

MOD(2n)

MOD(3n)

MOD(4n)

Timer starts

Compare register

(CR00)

INTC00

interrupt request

Rewriting by inter-
rupt program

Interval

Interval

Interval

Rewriting by inter-
rupt program

Rewriting by inter-
rupt program

Remark Interval = n

× 8/f

CLK

, 1

≤ n ≤ FFFFH

This manual is related to the following products: