The Peripheral Trigger Generator (PTG) is a user-programmable module on dsPIC33E/PIC24E Microcontrollers (MCUs). The PTG monitors peripheral activity and generates sequences of trigger signals to coordinate operation of the peripherals. The PTG is capability of producing a precisely-timed sequence of events which may be difficult to replicate with software.
The PTG is designed to work with the Analog-to-Digital Converter (ADC), the Output Compare/PWM module, all General Purpose Timers, and the MCU's Interrupt Controller.
PTG operation is controlled by a set of Step Commands loaded by the application into the PTG's queue. The depth of the PTG queue ranges from 8 to 32 depending upon which MCU is being used. Each step command is 8-bits wide.
Included in the Step Commands are one unconditional jump and two conditional jumps. Step Commands can be arranged in a single level nested loop configuration. Using Step Commands, the PTG can be instructed to pause operation to wait for an event to occur before proceeding.
Once the PTG is programmed and started, no additional CPU intervention is needed.
Step commands can detect the following inputs:
- An event trigger generated by a supported peripheral
- An interrupt request from the PWM or the ADC
- An external interrupt (INT2)
- A software trigger set by the application code
Step commands are capable of:
- Generating trigger signals for other peripheral's activity
- Changing the values of the parameters used by the peripherals
- Initiating a PTG interrupt request
- Disabling the step timer (i.e. stopping PTG execution)
Parameters for Program Flow Control
Step commands have the following mechanisms to control program flow:
- Unconditional jumps
- Conditional jumps on input trigger levels (high or low)
- Conditional jumps on a loop counter's value
The PTG's operating clock is set by the application. The options for the clock source include:
- ADC FRC
- The input clock for timer T1, T2, or T3