7540 Group
Rev.4.00
Jun 21, 2004
page 28 of 82
REJ03B0011-0400Z
qTimer Z
Timer Z is an 8-bit timer and counts the prescaler Z output.
When Timer Z underflows, the timer Z interrupt request bit is set to
“1”.
Prescaler Z is an 8-bit prescaler and counts the signal selected by
the timer Z count source selection bit.
Prescaler Z has the prescaler Z latch to retain the reload value.
Timer Z has the timer Z primary latch and timer Z secondary latch
to retain the reload value.
The value of prescaler Z latch is set to Prescaler Z when Prescaler
Z underflows.The value of timer Z primary latch or timer Z second-
ary latch are set to Timer Z when Timer Z underflows.
As for the value to transfer to Timer Z, either of timer Z primary or
timer Z secondary is selected depending on the timer Z operating
mode.
When writing to Prescaler Z (PREZ), timer Z primary (TZP) or
timer Z secondary (TZS) is executed, writing to “l(fā)atch only” or
“l(fā)atches and Prescaler Z and Timer Z” can be selected by the set-
ting value of the timer Z write control bit. Be sure to set the write
control bit because there are some notes according to the operat-
ing mode.
When reading from Prescaler Z (PREZ) is executed, the count
value of Prescaler Z is read out. When reading from timer Z pri-
mary (TZP) is executed, the count value of Timer Z is read out.
The count value of Timer Z can be read out by reading from the
timer Z primary (TZP) even when the value of timer Z primary
latch or timer Z secondary latch is counted. When reading the
timer Z secondary (TZS) is executed, the undefined value is read
out.
Timer Z can be selected in one of 4 operating modes by setting
the timer Z operating mode bits of the timer Y, Z mode register.
(1) Timer mode
Prescaler Z counts the count source selected by the timer Z count
source selection bits. Each time the count clock is input, the con-
tents of Prescaler Z is decremented by 1. When the contents of
Prescaler Z reach “0016”, an underflow occurs at the next count
clock, and the prescaler Z latch is reloaded into Prescaler Z. The
division ratio of Prescaler Z is 1/(n+1) provided that the value of
Prescaler Z is n.
The contents of Timer Z is decremented by 1 each time the under-
flow signal of Prescaler Z is input. When the contents of Timer Z
reach “0016”, an underflow occurs at the next count clock, and the
timer Z primary latch is reloaded into Timer Z and count continues.
(In the timer mode, the contents of timer Z primary latch is
counted. Timer Z secondary latch is not used in this mode.)
The division ratio of Timer Z is 1/(m+1) provided that the value of
Timer Z is m. Accordingly, the division ratio of Prescaler Z and
Timer Z is 1/((n+1)(m+1)) provided that the value of Prescaler Z
is n and the value of Timer Z is m.
In the timer mode, writing to “l(fā)atch only” or “l(fā)atches and Prescaler
Z and timer Z primary” can be selected by the setting value of the
timer Z write control bit.
(2) Programmable waveform generation mode
In the programmable waveform generation mode, timer counts the
setting value of timer Z primary and the setting value of timer Z
secondary alternately, the waveform inverted each time Timer Z
underflows is output from TZOUT pin.
When using this mode, be sure to set “1” to the timer Z write con-
trol bit to select “write to latch only”. Also, set the port P02 direction
registers to output mode.
The active edge of output waveform is set by the timer Z output
level latch (b4) of the timer Y, Z waveform output control register
(PUM). When “0” is set to b4 of PUM, “H” interval by the setting
value of TZP or “L” interval by the setting value of TZS is output al-
ternately. When “1” is set to b4 of PUM, “L” interval by the setting
value of TZP or “H” interval by the setting value of TZS is output
alternately.
Also, in this mode, the primary interval and the secondary interval
of the output waveform can be extended respectively for 0.5 cycle
of timer count source clock by setting the timer Z primary wave-
form extension control bit (b0) and the timer Z secondary
waveform extension control bit (b1) of PUM to “1”. As a result, the
When b0 and b1 of PUM are used, the frequency and duty of the
output waveform are as follows;
Waveform frequency:
FZOUT=
Duty:
DZOUT=
TMZCL: Timer Z count source (frequency)
TZP: Timer Z primary (8bit)
TZS: Timer Z secondary (8bit)
EXPZP: Timer Z primary waveform extension control bit (1bit)
EXPZS: Timer Z secondary waveform extension control bit (1bit)
In the programmable waveform generation mode, when values of
the TZP, TZS, EXPZP and EXPZS are changed, the output wave-
form is changed at the beginning (timer Z primary waveform
interval) of waveform period.
When the count values are changed, set values to the TZS,
EXPZP and EXPZS first. After then, set the value to TZP. The val-
ues are set all at once at the beginning of the next waveform
period when the value is set to TZP. (When writing at timer stop is
executed, writing to TZP at last is required.)
2TMZCL
2(TZP+1)+2(TZS+1)+(EXPZP+EXPZS)
2(TZP+1)+EXPZP
(2(TZP+1)+EXPZP)+(2(TZS+1)+EXPZS