PEmicro Blog

Custom Clock Trimming for Compatible ARM devices with Cyclone & PROGACMP

by Gilbert Yap on Nov 21, 2019

Along with clock multiplier and dividers, clock trimming offers a way for users to control the frequency of internal clocks in their target processors. Unlike multipliers and dividers, digital clock trimming allows changes to the internal clock through specific registers. Trim resolution can be any number of bits and different manufacturers provide different levels of trimming. Clocks are typically  trimmed to a specific value from the factory and are within a specific tolerance.

PEmicro has historically supported setting custom trim values for RS08, HCS08, ColdFire, and specific Kinetis ARM devices. Now, PEmicro ’s PROGACMP and Cyclone Standalone software adds support for the calculation and programming of custom trim values for new ARM devices. Currently the Cypress PSoC 4200L and NXP KE1xZ/KE1xF devices are supported, but this feature will be rolling out for more devices in the future. 

Manufacturing tolerances may guarantee that a processor’s clock speed is accurate within a certain percentage. Trimming, however, can allow users to acquire better accuracy or entirely change the clock frequency for their own application. For ARM devices that support custom trimming, calculating new trim values for a desired clock speed can be a tedious or difficult process every processor and board having different trim values for a specific frequency. Using our PROG or Cyclone software to obtain and program new trim values provides a quick and easy to use interface. This can be accomplished in two simple steps.

1. Providing a new clock frequency


For a device that supports custom trim, additional information in the “Configuration” window on the right hand side will be displayed. This includes “Desired Trim Reference Frequency” and a clickable “Change” box. Clicking the box will result in a pop up, asking the user to provide a new reference frequency. The valid range of frequencies is provided. The image below demonstrates the change from the default 24 MHz to 36 MHz. Finally, pressing “Commit Trim Change” will begin the trim calculation process.

Users can confirm that the trim calculation was successful by checking the right hand side of the PROGACMP window. The new, desired frequency should be displayed next to “Desired Trim Reference Frequency”. 

The level of trim frequency accuracy is given in the comments on the right hand side in the “Configuration” window. For example, the Cypress 4200L devices have an accuracy of +/- 0.3% and the KE1xZ and KE1xF devices have an accuracy of +/- 0.08%. Accuracy of the trim will be dependent on the number of bits provided by the chip manufacturer.

Cyclone Image Creation Utility 

For a device that supports custom trim, a new “Trim Control” configuration section will appear above the “Image Description” box. This region asks users if they would like to use a custom trim reference frequency and what they would like to set that frequency to. The valid range of frequencies is provided. The image above demonstrates the change from the default 24 MHz to 36 MHz. Leaving the box unchecked and performing the PT command will result in the default trim value being programmed.

2. Providing a flash location to program (optional in some cases)


Typically custom trim-supported devices have two configurations. The first configuration is the device having a dedicated nonvolatile register that trim values can be programmed into. The device will automatically load this value on startup or rely on the user's application to load this value into a volatile register when desired. The second configuration is the device not having a dedicated nonvolatile register. In this case, if a user would like to use a specific trim value, it must be saved in flash. Users should consult their target device’s reference manual to see if their target device will automatically update their trim register or if they will have to manually copy the value to a new location.

Our PROG and Cyclone software can detect if a device uses either the first or second configuration. In the case of the second configuration, a pop up will appear after selecting the PT command, prompting the user to input a flash location to program the trim values to. The value provided should be in hex format without a leading “0x”. The user is allowed to program the trim value to any valid flash address. 

The trim values will be programmed with the same width as the volatile register, as well include any surrounding setting bits. For example, if the trim bits are located in a 32-bit wide register and the trim bits are [7:0] along with clock divider in bits [10:8], these divider bits will be present in the user selected location. This is done to make it easier for users to update the volatile registers that may already have user configured settings. Users simply need to copy the entire width of the register from the program location and copy them to the volatile register.

Cyclone Image Creation Utility 

For the Cyclone Image Creation Utility, the steps are the same as PROGACMP. 


Custom trim programming for new ARM devices is also supported in the command line format, CPROGACMP. Since there is no pop up or box that can be used to set the desired frequency, users must put “:CUSTOMTRIMREF” near the top of their .cfg file, followed by the desired frequency. To utilize the PT command, the user will put “PT” in their script, as well as a valid flash location in hex. The hex address does not require a leading “0x”. Our recommendation is to perform PT close to the end script after verification of a programmed object file. Below is an example of a .cfg file used with CPROGACMP.

Tags related to this Blog Post

Cyclone     Cyclone FX     Multilink     Multilink FX     Prog ACMP     NXP     Cypress     Production Programming     Debug