Product Specs

Table Of Contents
47 PWM Pulse width modulation
Page
500
SEQ[n].PTR is the pointer used to fetch COMPARE values from RAM. If the SEQ[n].PTR is not pointing to
the Data RAM region, an EasyDMA transfer may result in a HardFault or RAM corruption. See Memory on
page 23 for more information about the different memory regions.
After the SEQ[n].PTR is set to the desired RAM location, the SEQ[n].CNT register must be set to the number
of 16-bit half words in the sequence. It is important to observe that the Grouped and Single modes require
one half word per group or one half word per channel respectively, and thus increases RAM size occupation.
If PWM generation was not running yet at that point, sending the SEQSTART[n] task will load the first
value from RAM, then start the PWM generation. A SEQSTARTED[n] event is generated as soon as the
EasyDMA has read the first PWM parameter from RAM and the wave counter has started executing it. When
LOOP.CNT=0, sequence n=0 or 1 is played back once. After the last value in the sequence has been loaded
and started executing, a SEQEND[n] event is generated. The PWM generation will then continue with the
last loaded value. See Figure 145: Simple sequence example on page 501 for an example of such simple
playback.
To completely stop the PWM generation and force the associated pins to a defined state, a STOP task
can be fired at any time. A STOPPED event is generated when the PWM generation has stopped at the
end of currently running PWM period, and the pins go into their idle state as defined in GPIO->OUT. PWM
generation can then only be restarted through a SEQSTART[n] task. SEQSTART[n] will resume PWM
generation after having loaded the first value from the RAM buffer defined in the SEQ[n].PTR register.
The table below provides indication of when specific registers get sampled by the hardware. Care should be
taken when updating these registers to avoid values to be applied earlier than expected.
Table 116: When to safely update PWM registers
Register
Taken into account by hardware
Recommended (safe) update
SEQ[n].PTR
When sending the SEQSTART[n] task
After having received the SEQSTARTED[n] event
SEQ[n].CNT
When sending the SEQSTART[n] task
After having received the SEQSTARTED[n] event
SEQ[0].ENDDELAY
When sending the SEQSTART[0] task
Every time a new value from sequence [0] has been loaded from
RAM and gets applied to the Wave Counter (indicated by the
PWMPERIODEND event)
Before starting sequence [0] through a SEQSTART[0] task
When no more value from sequence [0] gets loaded from RAM
(indicated by the SEQEND[0] event)
At any time during sequence [1] (which starts when the SEQSTARTED[1]
event is fired)
SEQ[1].ENDDELAY
When sending the SEQSTART[1] task
Every time a new value from sequence [1] has been loaded from
RAM and gets applied to the Wave Counter (indicated by the
PWMPERIODEND event)
Before starting sequence [1] through a SEQSTART[1] task
When no more value from sequence [1] gets loaded from RAM
(indicated by the SEQEND[1] event)
At any time during sequence [0] (which starts when the SEQSTARTED[0]
event is fired)
SEQ[0].REFRESH
When sending the SEQSTART[0] task
Every time a new value from sequence [0] has been loaded from
RAM and gets applied to the Wave Counter (indicated by the
PWMPERIODEND event)
Before starting sequence [0] through a SEQSTART[0] task
At any time during sequence [1] (which starts when the SEQSTARTED[1]
event is fired)
SEQ[1].REFRESH
When sending the SEQSTART[1] task
Every time a new value from sequence [1] has been loaded from
RAM and gets applied to the Wave Counter (indicated by the
PWMPERIODEND event)
Before starting sequence [1] through a SEQSTART[1] task
At any time during sequence [0] (which starts when the SEQSTARTED[0]
event is fired)
COUNTERTOP
In DECODER.LOAD=WaveForm: this register is ignored.
In all other LOAD modes: at the end of current PWM period (indicated
by the PWMPERIODEND event)
Before starting PWM generation through a SEQSTART[n] task
After a STOP task has been issued, and the STOPPED event has been
received.
MODE
Immediately
Before starting PWM generation through a SEQSTART[n] task
After a STOP task has been issued, and the STOPPED event has been
received.
DECODER
Immediately
Before starting PWM generation through a SEQSTART[n] task
After a STOP task has been issued, and the STOPPED event has been
received.
PRESCALER
Immediately
Before starting PWM generation through a SEQSTART[n] task
After a STOP task has been issued, and the STOPPED event has been
received.
LOOP
Immediately
Before starting PWM generation through a SEQSTART[n] task
After a STOP task has been issued, and the STOPPED event has been
received.
PSEL.OUT[n]
Immediately
Before enabling the PWM instance through the ENABLE register
Important: SEQ[n].REFRESH and SEQ[n].ENDDELAY are ignored at the end of a complex
sequence, indicated by a LOOPSDONE event. The reason for this is that the last value loaded from
RAM is maintained until further action from software (restarting a new sequence, or stopping PWM
generation).