Changing the default XTAL trim

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing the default XTAL trim

Changing the default XTAL trim

As mentioned in this other post, its important to have the correct trim on the external XTAL. However, once you have found the required trim to properly adjust the frequency, it is not very practical to manually adjust it in every device. So here is where changing the default XTAL trim comes in handy.

KW41Z

With the KW41 Connecitivity Software 1.0.2, it is a pretty straightforward process. In the hardware_init.c file, there is a global variable mXtalTrimDefault. To change the default XTAL trim, simply change the value of this variable. Remember it is an 8 bit register, so the maximum value would be 0xFF.

KW40Z

With the KW40, it is a similar process; however, it is not implemented by default on the KW40 Connectivity Software 1.0.1, so it should be implemented manually, following these steps:

  1. Create a global variable in hardware_init.c to store the default XTAL trim, similar to the KW41: 
    /* Default XTAL trim value */
    static const uint8_t mXtalTrimDefault = 0xBE;‍‍‍‍‍‍

  2. Overwrite the default XTAL trim in the hardware_init() function, adding these lines after NV_ReadHWParameters(&gHardwareParameters)
      if(0xFFFFFFFF == gHardwareParameters.xtalTrim)
      {
          gHardwareParameters.xtalTrim = mXtalTrimDefault;
      }‍‍‍‍‍‍‍‍

  3. Add this define to allow XTAL trimming in the app_preinclude.h file: 
    /* Allows XTAL trimming */
    #define gXcvrXtalTrimEnabled_d  1‍‍‍‍‍

  4. Once you have found the appropriate XTAL trim value, simply change it in the global variable declared in step 1.
Labels (1)
No ratings
Version history
Last update:
‎09-10-2020 01:39 AM
Updated by: