7540 Group User
’
s Manual
APPLICATION
2-77
2.5 Timer Y and timer Z
2.5.4 Programmable waveform generation mode (timer Y and timer Z)
The basic operation of Timer Y and Timer Z are the same. In this section, Timer Y is explained.
(1) Operation description
In the programmable waveform generation mode, timer counts the setting value of timer Y primary
(TYP) and the setting value of timer Y secondary (TYS) alternately, the waveform whose polarity is
inverted each time Timer Y underflows is output from P0
1
/TY
OUT
pin.
When using this mode, be sure to set
“
1
”
to the timer Y write control bit to select
“
write to latch only
”
.
Also, set the port P0
1
direction registers to output mode.
The active edge of output waveform is set by the timer Y output level latch. When
“
0
”
is set to the
timer Y output level latch,
“
H
”
interval by the setting value of TYP or
“
L
”
interval by the setting value
of TYS is output alternately. When
“
1
”
is set to the timer Y output level latch,
“
L
”
interval by the
setting value of TYP or
“
H
”
interval by the setting value of TYS 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 Y primary waveform
extension control bit (b2) and the timer Y secondary waveform extension control bit (b3) of PUM to
“
1
”
. As a result, the waveforms of more accurate resolution can be output.
When b2 and b3 of PUM are used, the frequency and duty of the output waveform are as follows;
Waveform frequency: FYOUT=
Duty: DYOUT=
TMYCL: Timer Y count source (frequency)
TYP: Timer Y primary
TYS: Timer Y secondary
EXPYP (1 bit): Timer Y primary waveform extension control bit
EXPYS (1 bit): Timer Y secondary waveform extension control bit
In the programmable waveform generation mode, when values of the TYP, TYS, EXPYP and EXPYS
are changed, the output waveform is changed at the beginning (timer Y primary waveform interval)
of waveform period.
When the count values are changed, set values to the TYS, EXPYP and EXPYS first. After then, set
the value to TYP. The values are set all at once at the beginning of the next waveform period when
the value is set to TYP. (When writing at timer stop is executed, writing to TYP at last is required.)
Timer Y can stop counting by setting
“
1
”
to the timer Y count stop bit.
Also, when timer Y underflows, the timer Y interrupt request bit is set to
“
1
”
.
Timer Y reloads the value of latch when counting is stopped by the timer Y 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.)
2
(TMYCL)
(2
(TYP+1)+EXPYP)+(2
(TYS+1)+EXPYS))
2
(TYP+1)+EXPYP
(2
(TYP+1)+EXPYP)+(2
(TYS+1)+EXPYS))