NuMicro® NUC029LEE/NUC029SEE
32-bit Arm
®
Cortex
®
-M0 Microcontroller
Aug, 2018
Page
255
of
497
Rev 1.00
N
U
MICRO
®
N
UC02
9L
E
E
/N
UC029
S
E
E
T
E
CHN
ICA
L R
E
F
E
R
E
NC
E
M
A
NU
A
L
6.9.4 Basic Configuration
The PWM pin functions are configured in GPA_MFP, GPB_MFP and GPE_MFP registers.
The PWM clock can be enabled in APBCLK[22:20]. The PWM clock source is selected by
CLKSEL1[31:28], CLKSEL2[5:4] and CLKSEL2[10:8].
6.9.5 Functional Description
6.9.5.1 PWM-Timer Operation
The PWM controller supports 2 operation types: Edge-aligned and Center-aligned type.
6.9.5.2 Edge-aligned PWM (down-counter)
In Edge-aligned PWM Output mode, the 16 bits PWM counter will starts down-counting from
CNRn to match with the value of the duty cycle CMRn (old), when this happen it will toggle the
PWMn generator output to low. The counter will continue down-counting to 0, at this moment, it
toggles the PWMn generator output to high and CMRn(new) and CNRn(new) are updated with
CHnMODE=1 and request the PWM interrupt if PWM interrupt is enabled(PWMIEn (PIER[3:0]) =
1).
The PWM period and duty control are configured by PWM down-counter register (CNR) and
PWM comparator register (CMR). The PWM-timer timing operation is shown in Figure 6.9-8. The
pulse width modulation follows the formula below and the legend of PWM-Timer Comparator is
shown as Figure 6.9-7. Note that the corresponding GPIO pins must be configured as PWM
function (enable POE and disable CAPENR) for the corresponding PWM channel.
PWM frequency = PWMxy_CLK/[(p1)*(clock divider)*(CNR+1)]; where xy,
could be 01, 23 or 45, depends on selected PWM channel.
Duty ratio = (CMR+1)/(CNR+1)
CMR >= CNR: PWM output is always high
CMR < CNR: PWM low width= (CNR-CMR) unit
[1]
; PWM high width = (CMR+1) unit
CMR = 0: PWM low width = (CNR) unit; PWM high width = 1 unit
Note
[1]: unit = one PWM clock cycle.
+
-
CMRn+1
CNRn
PWM-Timer
Comparator
Output
CNRn
CMRn
Update
new CMRn
Start
Initialize
PWM
PWM
Ouput
CMR+1
CNR+1
Note:
n= 0~3.
Figure 6.9-7 Legend of Internal Comparator Output of PWM-Timer