Last edited 4 years ago

How to activate HSI and CSI oscillators calibration

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

1 Article purpose[edit source]

The purpose of this article is to explain how to calibrate the HSI and CSI oscillators in the RCC, by using the TIM internal peripheral TIM12 and/or TIM15 assigned to the secure monitor (TF-A or OP-TEE).


These clocks are internal oscillators whose frequency can be affected by temperature and voltage variations. To achieve a good clock accuracy, it is important to provide a mechanism to compensate the effects of these variations.


The clock calibration algorithm is based on the comparison of a timer (fed by HSI or CSI) and a clock is derived from the HSE clock that is considered as always accurate.


TIM12 input 1 is connected to hsi_cal_ck

TIM12 input 2 is connected to csi_cal_ck

TIM15 input 7 is connected to hsi_cal_ck

TIM15 input 8 is connected to csi_cal_ck


Refer to STM32MP15 reference manuals for detailed information on the timers.


The algorithm is implemented in the secure monitor. It compares both clocks and programs a correction factor in the RCC peripheral. There are various ways to trigger this service:

- periodically by the secure monitor itself

- upon kernel request through a dedicated SMC

- upon Arm® Cortex®-M4 request through a SEV

2 How to activate the calibration[edit source]

This is done in the secure monitor device tree, in the stm32mp157c-<board>.dts file.

2.1 Configuring the timers[edit source]

The timers used for calibration must be dedicated in the secure context. It cannot be used at the same time by the non-secure world.

Example: timer12-input1 is used for HSI and timer12-input2 for CSI

  &timers12 {
             secure-status = "okay";
             st,hsi-cal-input = <1>;
             st,csi_cal-input = <2>;
  };
  &timers15 {
             secure-status = "disabled";
             st,hsi-cal-input = <7>;
             st,csi_cal-input = <8>;
  };

2.2 Enabling and configuring the calibration service[edit source]

This can be done by enabling options inside the clock device tree section