Changing the default XTAL trim

Document created by Pablo Noriega Navarro Employee on Oct 4, 2016Last modified by Pablo Noriega Navarro Employee on Oct 31, 2016
Version 2Show Document
  • View in full screen mode

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.
3 people found this helpful

Attachments

    Outcomes