Difference between revisions of "How to activate HSI and CSI oscillators calibration"

[quality revision] [quality revision]
m
 

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, 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]

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



<noinclude>

{{ArticleMainWriter | OlivierB}}
{{ReviewersList | GeraldB, OlivierB, LionelD, FabriceG}}
{{ArticleApprovedVersion | OlivierB | LoicP | No previous approved version | AnneJ - 4Feb'19 - 10487 | 8Feb'19}}

[[Category:How to run use cases]]</noinclude>

==Article purpose==
The purpose of this article is to explain how to calibrate the HSI and CSI oscillators in the [[RCC internal peripheral|RCC]], by using the [[TIM_internal_peripheral#Overview|TIM internal peripheral]] '''TIM12''' and/or '''TIM15''' assigned to the secure monitor ([[TF-A overview|TF-A]] or [[OP-TEE overview|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 resources#Reference manuals|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<sup>&reg;</sup> Cortex<sup>&reg;</sup>-M4 request through a SEV

==How to activate the calibration==

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

===Configuring the timers===
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>;
   };

===Enabling and configuring the calibration service===
This can be done by enabling options inside the [[Clock_device_tree_configuration_-_Bootloader_specific#HSI_and_CSI_clockclocks_calibration|clock device tree section]]

<noinclude>

{{PublicationRequestId | 10487 | 2019-02-04 | AnneJ}}

[[Category:How to run use cases]]</noinclude>
Line 1: Line 1:
<noinclude>
 
{{ArticleMainWriter | OlivierB}}
 
{{ReviewersList | GeraldB, OlivierB, LionelD, FabriceG}}
 
{{ArticleApprovedVersion | OlivierB | LoicP | No previous approved version | AnneJ - 4Feb'19 - 10487 | 8Feb'19}}
 
 
[[Category:How to run use cases]]
 
</noinclude>
 
 
 
 
==Article purpose==
 
==Article purpose==
 
The purpose of this article is to explain how to calibrate the HSI and CSI oscillators in the [[RCC internal peripheral|RCC]], by using the [[TIM_internal_peripheral#Overview|TIM internal peripheral]] '''TIM12''' and/or '''TIM15''' assigned to the secure monitor ([[TF-A overview|TF-A]] or [[OP-TEE overview|OP-TEE]]).
 
The purpose of this article is to explain how to calibrate the HSI and CSI oscillators in the [[RCC internal peripheral|RCC]], by using the [[TIM_internal_peripheral#Overview|TIM internal peripheral]] '''TIM12''' and/or '''TIM15''' assigned to the secure monitor ([[TF-A overview|TF-A]] or [[OP-TEE overview|OP-TEE]]).
Line 61: Line 52:
   
 
===Enabling and configuring the calibration service===
 
===Enabling and configuring the calibration service===
This can be done by enabling options inside the [[Clock_device_tree_configuration_-_Bootloader_specific#HSI_and_CSI_clock_calibration|clock device tree section]]
+
This can be done by enabling options inside the [[Clock_device_tree_configuration_-_Bootloader_specific#HSI_and_CSI_clocks_calibration|clock device tree section]]
  +
 
  +
<noinclude>
  +
{{PublicationRequestId | 10487 | 2019-02-04 | AnneJ}}
  +
 
  +
[[Category:How to run use cases]]
  +
</noinclude>