Datasheet

PIC16(L)F1782/3
DS41579D-page 212 Preliminary 2011-2012 Microchip Technology Inc.
24.3 Modes of Operation
All modes of operation use the period, rising edge, and
falling edge events to generate the various PWM
output waveforms.
The 3-phase 6-step PWM mode makes special use of
the software controlled steering to generate the
required waveform.
Modes of operation are selected with the PSMC
Control (PSMCxCON) register (Register 24-1).
24.3.1 SINGLE-PHASE MODE
The single PWM is the most basic of all the
waveshapes generated by the PSMC module. It
consists of a single output that uses all three events
(rising edge, falling edge and period events) to
generate the waveform.
24.3.1.1 Mode Features
No dead-band control available
PWM can be steered to any combination of the
following PSMC outputs:
- PSMCxA
- PSMCxB
- PSMCxC
- PSMCxD
- PSMCxE
- PSMCxF
Identical PWM waveform is presented to all pins
for which steering is enabled.
24.3.1.2 Waveform Generation
Rising Edge Event
All outputs with PxSTR enabled are set to the
active state
Falling Edge Event
All outputs with PxSTR enabled are set to the
inactive state
Code for setting up the PSMC generate the
single-phase waveform shown in Figure 24-4, and given
in Example 24-1.
EXAMPLE 24-1: SINGLE-PHASE SETUP
FIGURE 24-4: SINGLE PWM WAVEFORM – PSMCXSTR0 = 01H
; Single-phase PWM PSMC setup
; Fully synchronous operation
; Period = 10 us
; Duty cycle = 50%
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
BSF PSMC1STR0,P1STRA
BCF PSMC1POL, P1POLA
BSF PSMC1OEN, P1OEA
; set time base as source for all events
BSF PSMC1PRS, P1PRST
BSF PSMC1PHS, P1PHST
BSF PSMC1DCS, P1DCST
; enable PSMC in Single-Phase Mode
; this also loads steering and time buffers
MOVLW B’11000000’
MOVWF PSMC1CON
BANKSEL TRISC
BCF TRISC, 0 ; enable pin driver
1 2 3
PWM Period Number
Period Event
Rising Edge Event
Falling Edge Event
PSMCxA