Datasheet

2011-2012 Microchip Technology Inc. Preliminary DS41579D-page 213
PIC16(L)F1782/3
24.3.2 COMPLEMENTARY PWM
The complementary PWM uses the same events as
the single PWM, but two waveforms are generated
instead of only one.
The two waveforms are opposite in polarity to each
other. The two waveforms may also have dead-band
control as well.
24.3.2.1 Mode Features and Controls
Dead-band control available
PWM primary output can be steered to the
following pins:
- PSMCxA
- PSMCxC
- PSMCxE
PWM complementary output can be steered to
the following pins:
- PSMCxB
- PSMCxD
- PSMCxE
24.3.2.2 Waveform Generation
Rising Edge Event
Complementary output is set inactive
Optional rising edge dead band is activated
Primary output is set active
Falling Edge Event
Primary output is set inactive
Optional falling edge dead band is activated
Complementary output is set active
Code for setting up the PSMC generate the
complementary single-phase waveform shown in
Figure 24-5, and given in Example 24-2.
EXAMPLE 24-2: COMPLEMENTARY
SINGLE-PHASE SETUP
FIGURE 24-5: COMPLEMENTARY PWM WAVEFORM – PSMCXSTR0 = 03H
; Complementary Single-phase PWM PSMC setup
; Fully synchronous operation
; Period = 10 us
; Duty cycle = 50%
; Deadband = 93.75 +15.6/-0 ns
BANKSEL PSMC1CON
MOVLW 0x02 ; set period
MOVWF PSMC1PRH
MOVLW 0x7F
MOVWF PSMC1PRL
MOVLW 0x01 ; set duty cycle
MOVWF PSMC1DCH
MOVLW 0x3F
MOVWF PSMC1DCL
CLRF PSMC1PHH ; no phase offset
CLRF PSMC1PHL
MOVLW 0x01 ; PSMC clock=64 MHz
MOVWF PSMC1CLK
; output on A, normal polarity
MOVLW B’00000011’ ; A and B enables
MOVWF PSMC1OEN
MOVWF PSMC1STR0
CLRF PSMC1POL
; set time base as source for all events
BSF PSMC1PRS, P1PRST
BSF PSMC1PHS, P1PHST
BSF PSMC1DCS, P1DCST
; set rising and falling dead-band times
MOVLW D’6’
MOVWF PSMC1DBR
MOVWF PSMC1DBF
; enable PSMC in Complementary Single Mode
; this also loads steering and time buffers
; and enables rising and falling deadbands
MOVLW B’11110001’
MOVWF PSMC1CON
BANKSEL TRISC
BCF TRISC, 0 ; enable pin drivers
BCF TRISC, 1
1 2 3
Rising Edge Dead Band
Falling Edge Dead Band
Rising Edge Dead Band
Falling Edge Dead Band
Period Event
Rising Edge Event
Falling Edge Event
PSMCxA
PSMCxB
PWM Period Number
(Primary Output)
(Complementary Output)