Operations; Setting Procedure; Operation Example - Renesas M16C/64A Series User Manual

Table of Contents

Advertisement

M16C/64A Group
21.3

Operations

21.3.1

Setting Procedure

Follow the procedure below to set individual registers in order to start PWMi (i = 0, 1) output. (All SFRs
are assumed to be reset. Refer the register descriptions to access registers or bits.)
(1) Write output data of the port corresponding to the pin for PWMi output to the P9 or P4 register.
Then, set the direction bit for the corresponding port to 1 (output mode).
(2) Set the PWMSELi bit in the PWMCON0 register to select a pin for PWMi output. Set the PWMCLKi
bit to select the count source.
(3) Set registers PWMPREi and PWMREGi to set the PWM cycle and high-level pulse width.
(4) Set the PWMPORTi bit in the PWMCON1 register to 1 (PWMi function) and the PWMENi bit to 1
(PWM output enabled).
21.3.2

Operation Example

The values written to registers PWMPREi and PWMREGi during PWMi (i = 0, 1) output are not
reflected until the next cycle of PWMi output begins.
The PWM output signal is low immediately after the MCU is reset. Then, the associated waveform
output starts.
The PWMi output level remains unchanged even if the PWMENi bit in the PWMCON1 register is
changed from 1 (PWMi output enabled) to 0 (PWMi output disabled) during PWMi output. Registers
PWMPREi and PWMREGi retain the value before the PWMi output is disabled. When setting the
PWMENi bit to 1 after registers PWMPREi and PWMREGi are rewritten while PWMi output is disabled,
the values of registers PWMPREi and PWMREGi prior to the change are reflected for the first cycle of
PWM output. The rewritten register values are reflected in the following PWMi cycle.
Figure 21.2 to Figure 21.4 shows PWMi output examples.
PWMENi bit in the
PWMCON1
register
PWMi prescaler
prelatch
Reset value
PWMi register
prelatch
PWMi prescaler
latch
PWMi
register latch
PWMi output
This length of low-level signal is output for first cycle after reset.
i: 0, 1
fj: PWM count source frequency
The above diagram assumes the PWMPORTi bit in the PWMCON1 register is 1 (PWMi output).
Figure 21.2
PWMi Output Example (After Reset and During PWM Output)
R01UH0136EJ0210 Rev.2.10
Jul 31, 2012
Set to 1 (PWM output enabled) by a program
00h
m1
Set registers PWMPREi and PWMREGi by a program
00h
n1
00h
Reset value
00h
Rewritten reset value but before
PWMi output enabled is reflected in
the second cycle of PWMi output
(m1+1) × n1
Low-level output
-1) × (0+1)
8
(2
fj
m2
n2
m1
n1
Value rewritten during PWM output is reflected
in the next cycle
(m2+1) × n2
fj
-1) × (m1+1)
8
(2
fj
21. Pulse Width Modulator
m2
n2
fj
-1) × (m2+1)
8
(2
fj
Page 398 of 800

Advertisement

Table of Contents
loading

Table of Contents