NuMicro® NUC029LEE/NUC029SEE
32-bit Arm
®
Cortex
®
-M0 Microcontroller
Aug, 2018
Page
263
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.5.10 PWM-Timer Start Procedure
The following procedure is recommended for starting a PWM drive.
1.
Setup clock source divider select register (CSR)
2.
Wait until SYNCBUSYn be set to 0 by hardware (if PWM clock source is not from
HCLK)
3.
Setup prescaler (PPR)
4.
Wait until SYNCBUSYn be set to 0 by hardware (if PWM clock source is not from
HCLK)
5.
Setup inverter on/off, Dead-zone generator on/off, Auto-reload/One-shot mode and
Stop PWM-timer (PCR)
6.
Wait until SYNCBUSYn be set to 0 by hardware (if PWM clock source is not from
HCLK)
7.
Setup comparator register (CMR) for setting PWM duty.
8.
Wait until SYNCBUSYn be set to 0 by hardware (if PWM clock source is not from
HCLK)
9.
Setup PWM down-counter register (CNR) for setting PWM period.
10. Setup interrupt enable register (PIER) (optional)
11. Setup corresponding GPIO pins as PWM function (enable POE and disable CAPENR)
for the corresponding PWM channel.
12. Enable PWM timer start running (Set CHnEN = 1 in PCR)
6.9.5.11 Modify
PWM
counter
register
(CNR),
comparator
register
(CMR),
Clock
prescaler(CP01/CP23) and PWM operation mode(CHnMOD in PCR register bit3) Procedure
The following procedure is recommended for modifying CNR/CMR/Clock prescaler/PWM
operation mode.
1.
Wait until SYNCBUSYn be set to 0 by hardware (if PWM clock source is not from
HCLK)
2.
Modify CMRn/CNRn/CHnMOD/CP01/CP23
6.9.5.12 PWM-Timer Re-Start Procedure in Single-shot mode
After PWM waveform is generated once in PWM One-shot mode, PWM-Timer will be stopped
automatically and both of CNR and CMR will be cleared by hardware. Software must fill CMR and
CNR value again to re-start another PWM one-shot waveform. The following procedure is
recommended for re-starting PWM one-shot waveform.
1.
Wait until SYNCBUSYn be set to 0 by hardware (if PWM clock source is not from
HCLK)
2.
Setup comparator register (CMR) for setting PWM duty.
3.
Wait until SYNCBUSYn be set to 0 by hardware (if PWM clock source is not from
HCLK)
4.
Setup PWM down-counter register (CNR) for setting PWM period. After setup CNR,
PWM wave will be generated.