Specifications

dsPIC33F/PIC24H Family Reference Manual
DS70323E-page 43-62 © 2008-2012 Microchip Technology Inc.
Example 43-18: Independent PWM ADC Triggering
Note 1: The TRGSTAT bit is cleared only by clearing the TRGIEN bit (PWMCONx<10>). It
is not cleared automatically.
2: Dynamic triggering can show some advantages where multiple PWM channels are
used in applications such as IPFC and multi-phase buck regulators. TRIGx values
can be changed based on the PWM period, duty, load current, etc. This is to ensure
that the trigger points are separated from the PWM channel’s rise and fall
instances.
/* Independent PWM ADC triggering */
TRIG1 = 1248; /* Point at which the ADC module is to be
triggered by primary PWM */
STRIG1 = 2496; /* Point at which the ADC module is to be
triggered by secondary PWM */
TRGCON1bits.TRGDIV = 0; /* Trigger output divider set to trigger
ADC on every trigger match event */
TRGCON1bits.DTM = 1; /* Primary and Secondary triggers combined
to create ADC trigger */
TRGCON1bits.TRGSTRT = 4; /* First ADC trigger event occurs after
four trigger match events */
PWMCON1bits.TRGIEN = 1; /* Trigger event generates an interrupt
request */
while (PWMCON1bits.TRGSTAT = = 1);/* Wait for PWM trigger interrupt status
change */