on
2021-12-01
1:58 AM
- edited on
2025-03-17
6:13 AM
by
Laurids_PETERSE
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.
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:
Let’s see how to enable, configure and use the peripheral using our STM32CubeIDE.
Click Yes when the Board Project Options window pops up.
You will find the DTS in the Analog category in the Pinout and Configuration Tab.
Enable the Peripheral
We will configure the DTS as described earlier in the article:
Save the project, that will also generate the code.
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 */
After the project is built, enter a debug session
Now add the variable "Temperature" to the Live Watch Window.
Run the code:
You should now see the measured Temperature being displayed in degrees Celsius.
Please keep in mind that this is the die temperature and not the ambient temperature.
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
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)?