Information
dsPIC33FJ06GS001/101A/102A/202A and dsPIC33FJ09GS302
DS80000540E-page 4 2012-2013 Microchip Technology Inc.
3. Module: PWM
The PENH and PENL bits in the IOCONx register
are used to assign ownership of the pins to either
the PWM module or the GPIO module. The correct
procedure to configure the PWM module is to first
assign pin ownership to the PWM module and then
enabling it using the PTEN bit in the PTCON
register.
If the PWM module is enabled using the above
sequence, then a glitch may be observed on the
PWM pins before actual switching of the PWM
outputs begins. This glitch may cause momentary
turn ON of power MOSFETs that are driven by the
PWM pins and may cause damage to the
application hardware.
Work around
Perform the following steps to avoid any glitches
from appearing on the PWM outputs at the time of
enabling:
1. Configure the respective PWM pins to digital
inputs using the TRISx registers. This step will
put the PWM pins in a high-impedance state.
The PWM outputs must be maintained in a safe
state by using pull-up or pull-down resistors.
2. Assign pin ownership to the GPIO module by
configuring the PENH bit (IOCONx<15>) = 0
and the PENL bit (IOCONx<14>) = 0.
3. Specify the PWM override state to the desired
safe state for the PWM pins using the
OVRDAT<1:0> bit field in the IOCONx register.
4. Override the PWM outputs by setting
the OVRENH bit (IOCONx<9>) = 1 and
the OVRENL bit (IOCONx<8>) = 1.
5. Enable the PWM module by setting the PTEN
bit (PTCON<15>) = 1.
6. Remove the PWM overrides by making the
OVRENH bit (IOCONx<9>) = 0 and the OVRENL
bit (IOCONx<8>) = 0.
7. Ensure a delay of at least one full PWM cycle.
8. Assign pin ownership to the PWM module by
setting the PENH bit (IOCONx<15>) = 1 and
the PENL bit (IOCONx<14>) = 1.
The code in Example 1 illustrates the use of this work
around.
Affected Silicon Revisions
EXAMPLE 1: CONFIGURE PWM MODULE TO PREVENT GLITCHES ON PWM1H AND PWM1L
PINS AT THE TIME OF ENABLING
A1
X
TRISAbits.TRISA4 = 1; // Configure PWM1H/RA4 as digital input
// Ensure output is in safe state using pull-up or pull-down resistors
TRISAbits.TRISA3 = 1; // Configure PWM1L/RA3 as digital input
// Ensure output is in safe state using pull-up or pull-down resistors
IOCON1bits.PENH = 0; // Assign pin ownership of PWM1H/RA4 to GPIO module
IOCON1bits.PENL = 0; // Assign pin ownership of PWM1L/RA3 to GPIO module
IOCON1bits.OVRDAT = 0; // Configure PWM outputs override state to the desired safe state
IOCON1bits.OVRENH = 1; // Override PWM1H output
IOCON1bits.OVRENL = 1; // Override PWM1L output
PTCONbits.PTEN = 1; // Enable PWM module
IOCON1bits.OVRENH = 0; // Remove override for PWM1H output
IOCON1bits.OVRENL = 0; // Remove override for PWM1L output
Delay(x); // Introduce a delay greater than one full PWM cycle
IOCON1bits.PENH = 1; // Assign pin ownership of PWM1H/RA4 to PWM module
IOCON1bits.PENL = 1; // Assign pin ownership of PWM1L/RA3 to PWM module