on
2021-12-01
1:58 AM
- edited on
2025-12-17
5:21 AM
by
Laurids_PETERSE
The DTS (digital temperature sensor) was introduced in the high-performance STM32H7 series (STM32H72x/H73x). This temperature sensor is intended to measure in °C the die temperature called junction temperature (Tj) and not the ambient temperature (Ta). This article describes how to configure and use this peripheral on a STM32H723.
Figure 1. Nucleo-H723 board
The DTS generates a square wave with a frequency that is proportional to the temperature. The frequency is measured either with the PCLK or the LSE clock. This article shows how to configure and use this peripheral using the STM32CubeMX with a Nucleo-H723. Figure 2 shows the temperature sensor sequence measurement.
Figure 2. DTS sensor temperature measurement sequence
The frequency measurement starts by software. The reference clock used in this article is the high-speed clock which is PCLK. The quick measurement is disabled so the calibration starts automatically before the temperature measurement. According to the DTS specification, the counter clock must be slower than 1 MHz during the calibration phase and it is disabled automatically during the temperature measurement. As the DTS clock input exceeds that frequency, the divider must be used. For sampling time, 15 samples setting is used. A High and Low Threshold can be set to define a temperature window, that if exceeded, will generate an interrupt (that is, if the temperature is higher or lower than the thresholds).
Here is the block diagram of the DTS shown by figure 3: Figure 3. DTS block diagram
Let’s see how to enable, configure, and use the peripheral using STM32CubeMX in the next section.
Start the project based on a board by selecting [ACCESS TO BOARD SELECTOR] and type the board name as shown in the figure Figure 4. Select the board
Figure 8. DTS configuration
Declare the temperature variable that contains the current temperature Tj:
/* USER CODE BEGIN 0 */
int32_t temperature;
/* USER CODE END 0 */
In the while loop in the main:
while (1)
{
if(HAL_DTS_Start(&hdts)!= HAL_OK)
{
/* DTS start Error */
Error_Handler();
}
/* Get temperature in deg C */
if(HAL_DTS_GetTemperature(&hdts, &temperature)!= HAL_OK)
{
/* DTS GetTemperature Error */
Error_Handler();
}
/* Stop DTS peripheral */
if(HAL_DTS_Stop(&hdts)!= HAL_OK)
{
/* DTS stop Error */
Error_Handler();
}
HAL_Delay(2000);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
Figure 15 Run the application
The junction temperature is updated each 2 seconds in the Live Expression as shown in figure 16:Figure 16 The current junction temperature (Tj) is shown in °C.
This article provides the basics of the DTS temperature sensor embedded in STM32 MCUs and provided how to configure it using the PCLK clock with the quick measurement option disabled.
Thank you for this article. As far as I understood the DTS is not present on STM32H753 ? Is there a reason for this ?
Yes that is correct. DTS was added in new STM32H7. The STM323H743/53 was the first H7 introduced and does not have DTS.
The article about DTS is interesting, but debugging the DTS peripheral is not possible because the SVD file for STM32H733 doesn't contain the DTS description section.
Can ST have the DTS descriptor added to the SVD file for STM32H733 (and rest of the family)?