How to activate HSI and CSI oscillators calibration

Revision as of 13:47, 8 February 2019 by imported>Frq08906

Template:ArticleMainWriter Template:ReviewersList Template:ArticleApprovedVersion


1 Article purpose[edit]

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


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]

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

2.1 Configuring the timers[edit]

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]

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

3 References[edit]