Peripheral Trigger Generator - Step Commands

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

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.

Step Command Details

PTG Control Command (PTGCTRL)

Executes the control operation specified by the lower four bits of the commandOPTION<3:0>:

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

 Learn More

 
Initializing the PTG
Learn more >
 
PTG Step Commands
Learn more >
 
PTG Usage Examples
Learn more >

PTG Add (PTGADD)

Adds the contents ofPTGADJ to the contents of the target register, as specified by the lower four bits of the commandOPTION<3:0>:

OPTION<3:0>
0000 Add the contents ofPTGADJ to thePTGC0LIM register
0001 Add the contents ofPTGADJ to thePTGC1LIM register
0010 Add the contents ofPTGADJ to thePTGT0LIM register
0011 Add the contents ofPTGADJ to thePTGT1LIM register
0100 Add the contents ofPTGADJ to thePTGSDIM register
0101 Add the contents ofPTGADJ to thePTGL0 register

PTG Copy (PTGCOPY)

Copies the contents ofPTGHOLD to the contents of the target register as specified by the lower four bits of the commandOPTION<3:0>:

OPTION<3:0>
0000 Copy the contents ofPTGHOLD to thePTGC0LIM register
0001 Copy the contents ofPTGHOLD to thePTGC1LIM register
0010 Copy the contents ofPTGHOLD to thePTGT0LIM register
0011 Copy the contents ofPTGHOLD to thePTGT1LIM register
0100 Copy the contents ofPTGHOLD to thePTGSDIM register
0101 Copy the contents ofPTGHOLD to thePTGL0 register

Peripheral Trigger Generator Strobe (PTGSTRB)

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

Peripheral Trigger Generator 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>
0000 PWM Special Event Trigger
0001 PWM Master Timebase Synchronization Output
0010 PWM Interrupt 1
0011 PWM Interrupt 2
0100 PWM Interrupt 3
0111 OC1 Trigger Event
1000 OC2 Trigger Event
1001 IC1 Trigger Event
1010 CMP1 Trigger Event
1011 CMP2 Trigger Event
1100 CMP3 Trigger Event
1101 CMP4 Trigger Event
0110 ADC Conversion Done Interrupt
1111 INT2 External Interrupt

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

PTG Interrupt (PTGIRQ)

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

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

Peripheral Trigger Generator Trigger (PTGTRG)

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

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

PTG Jump (PTGJMP)

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

Peripheral Trigger Generator Jump Conditional 0 (PTGJMPC0)

Compares the value ofPTGC0 toPTGC0LIM.

IfPTGC0 >=PTGC0LIM

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

IfPTGC0 <PTGC0LIM

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

Peripheral Trigger Generator Jump Conditional 1 (PTGJMPC1)

Compares the value ofPTGC0 toPTGC0LIM.

IfPTGC1 >=PTGC1LIM

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

IfPTGC1 <PTGC1LIM

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

 Learn More