Setting the PTG Trigger Pulse Width

The PTGTRIG Step Command causes the Peripheral Trigger Generator (PTG) to generate one of the 32 trigger signals (PTGO0 - PTG3O1). These signals are used as control inputs to other MCU peripherals synchronizing activity. PTG trigger signals can be configured in one of the two modes:

  • In Toggle mode, the current value of the trigger signal will be toggled when PTGTRIG is executed.
  • In Pulse mode, PTGTRIG will trigger a one-time pulse on PTGOx. Here, the width of the pulse is set by the application program.

Selecting the Trigger Mode

The mode of the Trigger signal is determined by the Toggle Output Mode bit in the PTG Control and Status Register (PTGCST<12>).

PTGCST: PTG Status and Control Register

R/W-0 U-0 R/W-0 R/W-0 U-0 R/W-0 R/W-0 R/W-0
PTGEN PTGSIDL PTGTOGL PTGSWT PTGSSEN PTGVIS
bit 15 bit 8

R/W-0 R/W0 U-0 U-0 U-0 U-0 R/W-0 R/W-0
PTGSTRT PTGWDT0 PTGITM1 PTGITM0
bit 7 bit 0

bit 12

PTGTOGL: TRIG Output Toggle Mode bit

1 = Toggle the state of PTGOx on each PTGTRIG command
0 = Generate a single pulse on PTGOx on each PTGTRIG command

Determining the Pulse Width of the Trigger

When Trigger Pulse mode is selected, the width of the pulse is determined by a field in the PTG Control Register (PTGCON<7:4>).

PTGCON: PTG Control Register

R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0
PTGCLK2 PTGCLK1 PTGCLK0 PTGDIV4 PTGDIV3 PTGDIV2 PTGDIV1 PTGDIV0
bit 15 bit 8

R/W-0 R/W0 R/W0 R/W0 U-0 R/W-0 R/W-0 R/W-0
PTGPWD3 PTGPWD2 PTGPWD1 PTGWDT0 PTGWDT2 PTGWDT1 PTGWDT0
bit 7 bit 0

bit 7 - 4

PTGPWD<3:0>: PTG Trigger Output Pulse Width bits

1111 = All triggers are 16 PTG clock cycles
1110 = All triggers are 15 PTG clock cycles
*
*

0001 = All triggers are 2 PTG clock cycles
0000 = All triggers are 1 PTG clock cycles

Example Code

 Learn More

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.