19.11
Generating Arbitrary PWM Waveforms using Ganging
A comparator can be ganged together with its next-highest-numbered neighbor to generate arbi-
trary PWM pulses. When the
pwmcmp
gang
bit is set, comparator
fires and raises its
pwm
gpio
signal. When comparator
(or
pwmcmp0
for
pwmcmp3
) fires, the
pwm
gpio
out-
put is reset to zero.
19.12
Generating One-Shot Waveforms
The PWM peripheral can be used to generate precisely timed one-shot pulses by first initializing
the other parts of
pwmcfg
then writing a 1 to the
pwmenoneshot
bit. The counter will run for one
PWM cycle, then once a reset condition occurs, the
pwmenoneshot
bit is reset in hardware to
prevent a second cycle.
19.13
PWM Interrupts
The PWM can be configured to provide periodic counter interrupts by enabling auto-zeroing of
the count register when a comparator 0 fires (
pwmzerocmp
=1). The
pwmsticky
bit should also
be set to ensure interrupts are not forgotten while waiting to run a handler.
The interrupt pending bits
pwmcmp
ip
can be cleared down using writes to the
pwmcfg
register.
The PWM peripheral can also be used as a regular timer with no counter reset (
pwmzerocmp
=0),
where the comparators are now used to provide timer interrupts.
Chapter 19 Pulse Width Modulator (PWM)
SiFive FE310-G000 Manual: v3p2
© SiFive, Inc.
Page 103