Yes, OSDA can trim the reference of internal clock source!

Document created by Pavel Sadek Employee on Aug 8, 2013Last modified by Pavel Sadek Employee on Mar 8, 2016
Version 2Show Document
  • View in full screen mode

Trimming internal reference clock of ICS (internal clock source) module using OSDA connection

Pavel Šádek, Rožnov, Czech Republic

 

Simple apps does not require crystal driven clock precision. Internal reference clock based timing of MCU can be used instead.

 

Manufacturing process yealds to frequency deviation, that is why all MCU devices are factory programmed with a trim value in a reserved memory location. This value is uploaded to the ICS_C3 register and ICS_C4[SCFTRIM] during any reset initialization. For finer precision, trim the internal oscillator in the application and set ICS_C4[SCFTRIM] accordingly.

 

The TRIM bits effect the ICSOUT frequency if the ICS is in FLL engaged internal (FEI), FLL bypassed internal (FBI), or FLL bypassed internal low power (FBILP) mode.

 

The internal reference clock can be trimmed also in program time of the device to any value between 31.25 and 39.062kHz, this allows also achieving exotic bus frequencies. 

The value applied in Processor Expert does not propagate into Pemicro connection manager.

Výstřižek1.PNG

No matter if Processor expert is used or not , we need to configure it it by ourselves in connection of OSDA (same for debugging or programming). So this is a guide how to do so.

 

In the program initialization we need to initialize the ICS_C3 register and ICS_C4[SCFTRIM]. It can be done siply this way:

 

/* System clock initialization */

  if ( *((uint8_t*) 0x03FFU) != 0xFFU) {

    ICS_C3 = *((uint8_t*) 0x03FFU);

    ICS_C4 = (ICS_C4 & 0xFEU) | ((*((uint8_t*) 0x03FEU)) & 0x01U);

  }

 

Then hitVýstÅ™ižekBUG.PNG  flag, choose debug configuration and you will see configuration of your connectons, I have here only OSDA for my Kinetis E Freedom board (it is similar across families of Kinetis, ColdFire or S08 just connection would be SWD, Jtag or BDM)

Výstřižek2.PNG

You will get new window

 

Výstřižek3.PNG

Choose „Advanced Programming Options“ button

 

Výstřižek4.PNG

 

Enable calculating of Trim value and programming into Flash location.

If the TRIM frequency is different from default, check the box to use custom one in valid range – the one you(or Processor Expert) have used for your timing calculations.

Hit DONE and your effort is done!

 

Next, when you will launch debugging session by hitting bug on button VýstřižekBUG.PNG these values will be applied.

 

My RESULT:

 

ICS_C3 was trimmed to value of

0x57 for 39.062kHz and

0x9B for 31.250kHz

for my Kinetis E Freedom board.

Precision is better then 1% in room temp. This is ok for serial comunication without need of crystal for example.

Note:

Values out from my discovered range of 0x57 – 0x9B leads to frequencies that are out of specification of ICS and should not be used for this exact device.  The limits will be slightly different for every single device.

1 person found this helpful

Attachments

    Outcomes