PEmicro Blog

Cypress, NXP: Custom Clock Trimming/Calibration During Programming

Nov 21, 2019

Many MCU devices come with an uncalibrated internal clock which can have a center frequency which varies substantially from device to device.  Manufacturing tolerances generally guarantee that a processor’s clock speed is accurate within a wide percentage. Trimming the clock can allow users to calibrate the clocks to within a fairly accurate percentage (often within 0.2%). PEmicro hardware supports the process for auto-calculating and programming the trim values into many different Arm, RS08, HCS08, and ColdFire devices. 

Using PROG or Cyclone software to calculate and program a trim value provides a quick and easy to use interface. This can be accomplished in two simple steps.

1. Specify the desired clock frequency

PROGACMP Software

NOTE: The "SS" command shown in the screen captures below has since been replaced with the "QO" command (.s19, hex, elf) and "QB" command (.bin) depending on the type of data file. Please refer to this article.

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)

PROGACMP Software

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.

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. 

Using CPROGACMP

Custom trim programming for specific ARM devices is also supported in the command-line tool, 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