// include the XC header file to define all register and bit names
#include <xc.h>

//  Load Step Delay Limit register
PTGSDLIM = 4;    

// Sample Step Queuse
_STEP0 =   PTGWHI | 0;  
_STEP1 =   PTGCTRL |  6;  // enable Step Delay
_STEP2 =   PTGWHI | 1;    // wait for external trigger
_STEP3 =   PTGIRQ | 0;    // genearate PTG interrupt request
_STEP4 =   PTGCTRL | 2;   // disable Step Delay
_STEP5  =  JMP | 0;       // go to Step0 (i.e. repeat loop)