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) C
Executes the control operation specified by the lower four bits of the command OPTION<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 of PTGT0LIM |
1001 | Start PTG Timer1 and wait for its value to match the value of PTGT1LIM |
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 of PTGC0LIM to ADC1 Input Channel Select Register (AD1CHS0) |
1101 | Copy the contents of PTGC1LIM to ADC1 Input Channel Select Register |
1110 | Copy the contents of PTGL0 to ADC1 Input Channel Select Register |
1111 | Generate the triggers indicated by PTGBTE |
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> | |
0000 | Add the contents of PTGADJ to the PTGC0LIM register |
0001 | Add the contents of PTGADJ to the PTGC1LIM register |
0010 | Add the contents of PTGADJ to the PTGT0LIM register |
0011 | Add the contents of PTGADJ to the PTGT1LIM register |
0100 | Add the contents of PTGADJ to the PTGSDIM register |
0101 | Add the contents of PTGADJ to the PTGL0 register |
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> | |
0000 | Copy the contents of PTGHOLD to the PTGC0LIM register |
0001 | Copy the contents of PTGHOLD to the PTGC1LIM register |
0010 | Copy the contents of PTGHOLD to the PTGT0LIM register |
0011 | Copy the contents of PTGHOLD to the PTGT1LIM register |
0100 | Copy the contents of PTGHOLD to the PTGSDIM register |
0101 | Copy the contents of PTGHOLD to the PTGL0 register |
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.
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> | |
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 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 command OPTION<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 |
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 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 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
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