Initialize the MCU Peripherals
The Peripheral Trigger Generator (PTG) coordinates and sequences events between selected peripherals. The PTG works with the Analog-to-Digital Converter (ADC), the Output Compare/Pulse-Width Modulation (PWM) module, all General Purpose Timers, and the MCU's Interrupt Controller.
The mechanisms used to coordinate peripheral activities are triggers and Interrupt Requests (IRQs). The PTG can be programmed to either output a trigger, or to generate a PTG IRQ, based upon a trigger received from another peripheral. Successful sequencing depends upon careful coordination of the initialization of the PTG and PTG-monitored peripherals. Peripherals used in PTG sequences must be programmed to accept the appropriate PTG trigger(s) and, when needed, send a trigger to the PTG.
Example of Coordinating Trigger Assignments
The PTG on the dsPIC33EP256GP506 is capable of sending a trigger to the Output Compare (OC) module. This PTG-generated trigger can serve as the OC module's clock or sync signal. The OC module can also generate a trigger signal for the PTG to monitor. The OC module generated trigger is seen by the PTG as either OC1 or OC2 trigger.
To allow a PTG generated trigger to be the clock source for the OC module, OCxCON1 must be programmed.
OCxCON2 can be programmed to allow a PTG generated trigger to synchronize the OC module. For sequences in which the PTG generates IRQ, it is imperative that the MCU's interrupt controller be initialized so that the PTG IRQs are enabled.
Please consult the datasheet for the MCU you are using to verify the initialization requirements.