Peripheral Trigger Generator - Step Commands

Last modified by Microchip on 2023/11/09 09:00

Step Command Format

There are eleven 8-bit Step commands available to the Peripheral Trigger Generator (PTG). Each of the Step commands has two fields:

  • CMD<3:0>: 4-bit description of the operation to be performed
  • OPTION<3:0>: parameter that clarifies either the source or destination operand

8-bit Step Command Format

Executing Step Commands

Step commands are executed from the PTG's queue. The commands are placed into the queue by the application program. This queue is typically programmed during the application's start-up process rather than the main loop. Depending upon which MCU is being used, between eight and 32 Step commands can be programmed into the queue.

Once the queue is programmed the application will enable (PTGEN=1), then start (PTGSTRT=1) the PTG. The Step Queue Pointer Register (PTGQPTR) acts as a program counter controlling access to the PTG Step commands. When the PTG is enabled, PTGQPTR points to the first entry in the queue. The PTG sequentially decodes and executes instructions, incrementing PTGQPTR as each Step command is executed. Using the Jump Step commands, PTGQPTR can be altered to control program flow.

Image Shows how Step Queue Pointer Register (PTGQPTR) acts as Program Counter

Back to top

Step Command Details

PTG Control Command (PTGCTRL) C

Executes the control operation specified by the lower four bits of the command OPTION<3:0>.

OPTION<3:0> 
0010Disable the Step delay timer
0110Enable the Step delay timer
1000Start PTG Timer0 and wait for its value to match the value of PTGT0LIM
1001Start PTG Timer1 and wait for its value to match the value of PTGT1LIM
1010Wait for the software trigger PTGSWT (PTGCST<10>) to achieve a level of 1
1011Wait for the software trigger PTGSWT to transition from 0 to 1
1100Copy the contents of PTGC0LIM to ADC1 Input Channel Select Register (AD1CHS0)
1101Copy the contents of PTGC1LIM to ADC1 Input Channel Select Register
1110Copy the contents of PTGL0 to ADC1 Input Channel Select Register
1111Generate the triggers indicated by PTGBTE

Back to top

PTG Add (PTGADD)

Adds the contents of PTGADJ to the contents of the target register, as specified by the lower four bits of the command OPTION<3:0>.

OPTION<3:0> 
0000Add the contents of PTGADJ to the PTGC0LIM register
0001Add the contents of PTGADJ to the PTGC1LIM register
0010Add the contents of PTGADJ to the PTGT0LIM register
0011Add the contents of PTGADJ to the PTGT1LIM register
0100Add the contents of PTGADJ to the PTGSDIM register
0101Add the contents of PTGADJ to the PTGL0 register

Back to top

PTG Copy (PTGCOPY)

Copies the contents of PTGHOLD to the contents of the target register as specified by the lower four bits of the command OPTION<3:0>.

OPTION<3:0> 
0000Copy the contents of PTGHOLD to the PTGC0LIM register
0001Copy the contents of PTGHOLD to the PTGC1LIM register
0010Copy the contents of PTGHOLD to the PTGT0LIM register
0011Copy the contents of PTGHOLD to the PTGT1LIM register
0100Copy the contents of PTGHOLD to the PTGSDIM register
0101Copy the contents of PTGHOLD to the PTGL0 register

Back to top

PTG Strobe (PTGSTRB)

Copies the values contained in the bits CMD<0>:OPTION<3:0> to Channel 0 Positive Input Select for Sample A bits (CH0SA<4:0>) in the ADC1 Input Channel 0 Select Register AD1CHS0.

Back to top

PTG Wait for High (PTGWHI)

Waits (Pause PTG) until the trigger selected by the lower four bits of the command (CMD<3:0>) goes from Low to High.

OPTION<3:0> 
0000PWM Special Event Trigger
0001PWM Master Timebase Synchronization Output
0010PWM Interrupt 1
0011PWM Interrupt 2
0100PWM Interrupt 3
0111OC1 Trigger Event
1000OC2 Trigger Event
1001IC1 Trigger Event
1010CMP1 Trigger Event
1011CMP2 Trigger Event
1100CMP3 Trigger Event
1101CMP4 Trigger Event
0110ADC Conversion Done Interrupt
1111INT2 External Interrupt

Back to top

PTG Wait for Low (PTGWLO)

Waits (Pause PTG) until the trigger selected by the lower four bits of the command (CMD<3:0>) goes from High to Low.

OPTION<3:0> 
0000PWM Special Event Trigger
0001PWM Master Timebase Synchronization Output
0010PWM Interrupt 1
0011PWM Interrupt 2
0100PWM Interrupt 3
0111OC1 Trigger Event
1000OC2 Trigger Event
1001IC1 Trigger Event
1010CMP1 Trigger Event
1011CMP2 Trigger Event
1100CMP3 Trigger Event
1101CMP4 Trigger Event
0110ADC Conversion Done Interrupt
1111INT2 External Interrupt

Back to top

PTG Interrupt (PTGIRQ)

Generates a PTG interrupt request as specified by the lower four bits of the command OPTION<3:0>.

OPTION<3:0> 
0000Generate PTG interrupt 0
0001Generate PTG interrupt 1
0010Generate PTG interrupt 2
0011Generate PTG interrupt 3

Back to top

PTG Generate Trigger (PTGTRG)

Generates a PTG Trigger as specified by the lower five bits of the command CMD<0>:OPTION<3:0>.

CMD<0>
OPTION<3:0>
 
0 0000Generate PTGO0
0 0001Generate PTGO1
 …
1 1110Generate PTGO30
1 1111Generate PTGO31

Back to top

PTG Jump (PTGJMP)

Copies the lower five bits of the command CMD<0>:OPTION<3:0> into the PTG's queue pointer, PTGQPTR, then jumps to the newly designated step command.

PTG Jump Conditional 0 (PTGJMPC0)

Compares the value of PTGC0 to PTGC0LIM.

If PTGC0 >= PTGC0LIM

  • The next instruction in the queue is executed (i.e., no jump taken)
  • PTGC0 is set to 0

If PTGC0 < PTGC0LIM

  • The lower five bits of the instructions (CMD<0>:OPTION<3:0>) are copied into the PTGQPTR register (i.e., jump taken)
  • PTGC0 is incremented by 1

Back to top

PTG Jump Conditional 1 (PTGJMPC1)

Compares the value of PTGC0 to PTGC0LIM.

If PTGC1 >= PTGC1LIM

  • The next instruction in the queue is executed (i.e., no jump taken)
  • PTGC1 is set to 0

If PTGC1 < PTGC1LIM

  • The value of the lower five bits of the instructions (CMD<0>:OPTION<3:0>) is copied into the PTGQPTR register (i.e., jump taken)
  • PTGC1 is incremented by 1

Learn More

Back to top