Enabling and Starting the PTG Module
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 (PTGCST) register.
PTGCST: PTG Status and Control Register
R/W-0 | U-0 | R/W-0 | R/W-0 | U-0 | R/W-0 | R/W-0 | R/W-0 |
PTGEN | — | PTGSIDL | PTGTOGL | — | PTGSWT | PTGSSEN | PTGVIS |
bit 15 | bit 8 |
R/W-0 | R/W0 | U-0 | U-0 | U-0 | U-0 | R/W-0 | R/W-0 |
PTGSTRT | PTGWDT0 | — | — | — | — | PTGITM1 | PTGITM0 |
bit 7 | bit 0 |
bit 15
PTGEN: Module Enable bit
1 = Enables the PTG module
0 = Disables the PTG module
bit 7
PTGSTRT: Start PTG Sequencer bit
1 = Starts to sequentially execute Step commands
0 = Stops 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.