cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure and use the DTS (Digital Temperature Sensor) on the STM32H7

ST AME Support NF
ST Employee

How to configure and use the DTS (Digital Temperature Sensor) on the STM32H7

1. Introduction

The DTS (Digital Temperature Sensor) was introduced in our high performance STM32H7 family. In this article we will see how to configure and use this peripheral on a STM32H723.
 

2. Prerequisites

  • Hardware
    • Micro USB cable used to power the Nucleo board from a host machine and to load the code into the STM32
    • Nucleo-H723

1703.png
  • Software: STM32CubeIDE
 

3. Theory

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.  In this article we will learn how to configure and use this peripheral using the STM32CubeIDE and a Nucleo-H723.
The frequency measurement will be started using software. The Reference clock will be the high-speed clock which is PCLK with no divider and will measure with calibration so the quick measurement will be disabled.  For Sampling Time, we will use 15 samples. A High and Low Threshold can be set to define a temperature window, that if exceeded, will generate an interrupt (i.e., if the temperature is higher or lower than the thresholds).
Here is the block diagram of the DTS: 1704.png
Let’s see how to enable, configure and use the peripheral using our STM32CubeIDE.

 

4. Steps 

  1. Open STM32CubeIDE

  2. Create a new project using the NUCLEO-H723 board


1705.png
 
  1. Give a name to the project


1706.png
 
  1. Initialize all peripherals with their default settings

Click Yes when the Board Project Options window pops up.
1707.png
  1. Configure DTS

You will find the DTS in the Analog category in the Pinout and Configuration Tab.
1708.png
  1. Enable DTS

Enable the Peripheral
1709.png
  1. Configure DTS

We will configure the DTS as described earlier in the article:
  • Start the measurement using software.
  • The Reference clock will be the high-speed reference clock which is PCLK with no divider.
  • We will measure with calibration so the quick measurement will be disabled.
  • For Sampling Time, we will use 15 samples to get the highest precision.
  • No thresholds will be used in this example
1710.png
  1. Generate Code

Save the project, that will also generate the code.

  1. Add code to main.c

First we will declare a variable to store the temperature we will measure.
/* USER CODE BEGIN PV */
static int32_t Temperature;
/* USER CODE END PV */
Let’s add some code to start the peripheral, start as measurement, stop and the de-init the DTS.
  /* USER CODE BEGIN 2 */
  /* Start DTS peripheral */
    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();
    }

    /* De-initialize DTS peripheral */
    if(HAL_DTS_DeInit(&hdts) != HAL_OK)
    {
      /* DTS De-initialization Error */
      Error_Handler();
    }

  /* USER CODE END 2 */


  1. Build the project, enter debug mode and run the code

1711.png
After the project is built, enter a debug session
1713.png
Now add the variable "Temperature" to the Live Watch Window.
Run the code:
1715.png
You should now see the measured Temperature being displayed in degrees Celsius.
1716.png
Please keep in mind that this is the die temperature and not the ambient temperature.


5. Links

Datasheet - STM32H723VE STM32H723VG STM32H723ZE STM32H723ZG - 32-bit Arm® Cortex®-M7 550 MHz MCU, up to 1 MB Flash memory, 564 KB RAM, 35 comms peripherals and analog interfaces
STM32H723/733, STM32H725/735 and STM32H730 Value line advanced Arm®-based 32-bit MCUs - Reference manual
STM32CubeIDE - Integrated Development Environment for STM32 - STMicroelectronics
NUCLEO-H723ZG - STM32 Nucleo-144 development board with STM32H723ZG MCU, supports Arduino, ST Zio and morpho connectivity - STMicroelectronics
Comments
Gpeti
Senior II

Thank you for this article. As far as I understood the DTS is not present on STM32H753 ? Is there a reason for this ?

ST AME Support NF
ST Employee

Yes that is correct. DTS was added in new STM32H7. The STM323H743/53 was the first H7 introduced and does not have DTS.

mauro2399
Associate II

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)?

Version history
Last update:
‎2021-12-01 01:58 AM
Updated by: