In order for the Peripheral Trigger Generator (PTG) to begin executing Step Commands two separate actions must be taken by the application:
- The PTG must first be Enabled
- Once enabled, the PTG will begin operating when it is Started
Enabling and Starting the PTG are accomplished by writing to the PTG Control and Status Register PTGCST.
PTGCST: PTG Status and Control Register
|bit 15||bit 8|
|bit 7||bit 0|
PTGEN: Module Enable bit
1 = Enables the PTG module
0 = Disables the PTG module
PTGSTRT: Start PTG Sequencer bit
1 = Start to sequentially execute Step commands
0 = Stop executing commands
Examples of Enabling/Starting the PTG using the MPLAB® XC16 C Compiler
Notes to remember on Enabling and Starting the PTG
- At reset the PTG module is Disabled and Stopped.
- PTGCST is the only PTG Special Function Register (SFR) which can be written while the PTG Module is enabled. To modify any other PTG SFR you must first disable the PTG by clearing PTGEN.
- When PTGEN is set, the PTG Queue Pointer Register (PTGQPTR) is set to point to the first entry in the Step Queue. Starting and stopping PTG execution has no effect on PTGQPTR.