Loading Step Commands into the Queue
Step commands are executed from the Peripheral Trigger Generator (PTG) Step queue. The Step queue is a set of 16-bit wide special function registers (SFRs). The number of entries in the queue varies depending upon which MCU is being used. The SFRs in the queue are PTGQUE0 through PTGQUEn (where n = ( # of Step commands/2 ) - 1). Two 8-bit wide Step Commands are loaded into each 16-bit wide Step queue SFR.
Compiler Supplied #defines
The Step queue is loaded with a series of assignment statements. When <xc.h> is included in a project the MPLAB® XC16 compiler provides easy-to-read definitions for the individual queue entries (e.g., _STEP0, _STEP1, etc..). The compiler definitions ensure the proper placement of Step Commands.
Application #defines
A common mechanism used in application programs is to #define the commands in such a way as to make the loading of the queue more readable. Using this mechanism the #define includes the numeric opcode left shifted by 4 bits. Combined with the numeric for the OPTION field, this mechanism allows you to easily see what has been loaded into the queue.