Intel 80C196NU ユーザーズマニュアル

ページ / 471
8XC196NP, 80C196NU USER’S MANUAL
6-32
When the next timer match occurs, the PTS cycle (Figure 6-16) increments EPA0_TIME by T1
(if TBIT is zero (output = 0)) or T2 – T1 (if TBIT is one (output = 1)). (Note that although the
values of the EPA0 output and TBIT are the same in this example, these two values are unrelated.
To establish the initial value of the output, set or clear P1_REG.x.)
The PWM toggle mode has the advantage of using only one EPA channel. However, if the wave-
form edges are close together, the PTS may take too long and miss setting up the next edge. The
PWM remap mode uses two EPA channels to eliminate this problem.
6.6.5.2
PWM Remap Mode Example
Figure 6-17 shows the PTS control block for PWM remap mode. The following example uses two
EPA channels and a single timer to generate a PWM waveform in PWM remap mode. EPA0 as-
serts the output, and EPA1 deasserts it. For each channel, an interrupt is generated every T2 pe-
riod, but the comparison times for the channels are offset by the on-time, T1 (see Figure 6-14 on
page 6-27). Although TBIT is toggled at the end of every PWM remap mode cycle (see Table 6-7
on page 6-26), it plays no role in this mode. To generate a PWM waveform, follow this procedure.
1.
Disable the interrupts and the PTS. The DI instruction disables all interrupts; the DPTS
instruction disables the PTS.
2.
Set up one PTSCB for EPA0 and one for EPA1 as shown in Table 6-9. Note that the two
blocks are identical, except that PTSPTR1 points to EPA0_TIME for EPA0 and to
EPA1_TIME for EPA1.
3.
Configure P1.1 to serve as the EPA1 output. (Because EPA0 is not used as an output, port
pin P1.0 can be used for standard I/O.)
— Clear P1_DIR.1 (selects output).
— Set P1_MODE.1 (selects the EPA0 special-function signal).
— Set P1_REG.1 (initializes the output to “1”).