Establishing Step Command Timing

Establishing Step Command Timing

When setting up the clock controlling the execution speed of the Peripheral Trigger Generator (PTG) Step Commands, three parameters need to be considered:

  1. The signal used as the base clock source for the PTG Module.
  2. The number of clock periods needed for each Step Command cycle (prescaler).
  3. Whether or not the sequence will need to extend the clock cycle (step delay timer).

Clock Source and Prescaler

The PTG Control Register (PTGCON) controls the clock source and the prescale value for the PTG module. There are six signals which can be set as the PTG clock. Once the clock has been determined, the application can divide the clock by a value between 1 and 32.

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 15-13

PTGCLK<2:0>: Select PTG Module Clock

111 = Reserved
110 = Reserved
101 = Clock source will be T3CLK
100 = Clock source will be T2CLK
011 = Clock source will be T1CLK
010 = Clock source will be ADC FRC clock
001 = Clock source will be Fosc
000 = Clock source will be Fp

bit 12-8

PTGDIV<4:0>: PTG Clock module Prescaler (Divider) value

11111 = Divide by 32
11110 = Divide by 31
*
*
*
0001 = Divide by 2
0000 = Divide by 1

Selecting the PTG clock and prescaler using the MPLAB® XC16 C Compiler

Delaying PTG Step cycle.

Using the PTG Step Delay Limit register (PTGSDLIM) causes the Step Commands lot to execute at a slower rate than the period set by PTGCON. When enabled, PTGSDLIM acts as a second prescaler for the PTG Module. The PTG clock will be divided by the value of PTGSDLIM. The use of the step delay timer is optional, as it can be enabled or disabled at runtime by using the PTGCTRL Step Command.

  • PTGCTRL with <OPTION> = 0b0010 (2) Disables the Step Delay.
  • PTGCTRL with <OPTION> = 0b0110 (6) Enables the Step Delay.

 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.