7540 Group User
’
s Manual
2-84
APPLICATION
2.5 Timer Y and timer Z
2.5.5 Programmable one-shot generation mode (timer Z)
(1) Operation description
In the programmable one-shot generation mode, the one-shot pulse by the setting value of timer Z
primary can be output from P0
2
/TZ
OUT
pin by software or external trigger to the P3
7
/INT
0
pin. When
using this mode, be sure to set
“
1
”
to the timer Z write control bit to select
“
write to latch only
”
. Also,
set the port P0
2
direction registers to output mode. In this mode, the timer Z secondary (TZS) is not
used.
The active edge of output waveform is set by the timer Z output level latch. When
“
0
”
is set to the
timer Z output level latch,
“
H
”
pulse during the interval of the timer Z primary (TZP) setting value is
output. When
“
1
”
is set to the timer Z output level latch,
“
L
”
pulse during the interval of the TZP
setting value is output.
Also, in this mode, the interval of the one-shot pulse output can be extended for 0.5 cycle of timer
count source clock by setting the timer Z primary waveform extension control bit (EXPZP) to
“
1
”
.
As a result, the waveforms of more accurate resolution can be output.
During the one-shot pulse output interval, the one-shot pulse output can be stopped forcibly by
writing
“
0
”
to the timer Z one-shot start bit.
In the programmable one-shot generation mode, when the count values are changed, set value to
the EXPZP first. After then, set the value to TZP. The values are set all at once at the beginning of
the next one-shot pulse when the value is set to TZP. (Even when writing at timer stop is executed,
writing to TZP at last is required.)
Timer Z can stop counting by setting
“
1
”
to the timer Z count stop bit.
Also, when timer Z underflows, the timer Z interrupt request bit is set to
“
1
”
.
Timer Z reloads the value of latch when counting is stopped by the timer Z count stop bit.
(When timer is read out while timer is stopped, the value of latch is read. The value of timer can be
read out only while timer is operating.)
Notes 1:
In the programmable one-shot generation mode, the value of EXPZP becomes valid by
writing to TZP. Even when changing TZP is not required, write the same value again.
2:
In the programmable one-shot generation mode, when the setting value is changed while
the waveform is output, set by software in order not to execute the writing to TZP and the
timing of timer underflow simultaneously.
An example of a measurement is shown below.
ex.) The underflow of timer is stored by polling etc. using timer Z interrupt.
Writing to primary is performed in by judging that there is no problem if the underflow
by secondary is completed with reference to primary write operation before.
(Depending on a primary setting value, primary write timing, software and timing of
external trigger to INT
0
pin, it may be impossible.)
3:
The waveform extension function by the timer Z waveform extension control bits can be
used only when
“
00
16
”
is set to Prescaler Z.
When the value other than
“
00
16
”
is set to Prescaler Z, be sure to set
“
0
”
to EXPZP. Also,
when the timer Y underflow is selected as the timer Z count source, the waveform extension
function cannot be used.
4:
When using this mode, be sure to set
“
1
”
to the timer Z write control bit to select
“
write to
latch only
”
.
5:
In order to use TZ
OUT
pin, set
“
1
”
to bit 2 of the port P0 direction register (output mode).
6:
Stop Timer Z to change the INT
0
pin one-shot trigger control bit and INT
0
pin one-shot
trigger active edge selection bit.
Figure 2.5.28 shows the timing diagram of the programmable one-shot generation mode.