Enabling and Starting the PTG Module

Last modified by Microchip on 2023/11/10 11:07

In order for the Peripheral Trigger Generator (PTG) to begin executing step commands, two separate actions must be taken by the application:

  1. The PTG must first be enabled.
  2. 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.

Back to top

PTGCST: PTG Status and Control Register

PTG Control and Status Register with Enable and Start Bits Highlighted

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

Back to top

Example of Enabling/Starting the PTG Using the MPLAB® XC16 C Compiler

1
2
3
4
5
6
7
// include the XC header file to define all register and bit names
#include <xc.h>

PTGEN = 1;     // enables the PTG Module
PTGEN = 0;     // disables the PTG Module
PTGSTRT = 1;   // starts Step command executions
PGTSTRT = 0 ;  // stops execution

Back to top

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) that 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.

Back to top

Learn More

Programming the PTG

Establishing Step Command Timing

Initializing the PTG

Example PTG Code

Back to top