0% found this document useful (0 votes)
117 views

SPC58xx Temperature Sensor: Technical Note

Uploaded by

dipak1304
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views

SPC58xx Temperature Sensor: Technical Note

Uploaded by

dipak1304
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

TN1339

Technical note

SPC58xx temperature sensor

Introduction
The aim of this document is to detail the usage of the temperature sensor on SCP58xx microcontroller family.
The document provides the necessary information about the hardware and a reference code to calculate the temperature.
All the microcontrollers (MCU) listed in Table 1. Devices list include a temperature sensor (TSENS) that monitors device junction
temperature.
More details about the TSENS can be found in the device's reference manual (see Section Appendix B Reference documents).
Note: SPC582Bx MCU does not support TSENS.
Table 1. Devices list

Device Part number

SPC584Bx SPC584B60x, SPC584B64x, SPC584B70x


SPC584Cx/SPC58ECx SPC584C70x, SPC584C74x, SPC584C80x, SPC58EC70x, SPC58EC74x, SPC58EC80x
SPC584Gx/SPC58EGx SPC584G80x, SPC584G84x, SPC58EG80x, SPC58EG84x, SPC58NG80x, SPC58NG84x
SPC58EHx/SPC58NHx SPC58EH84x, SPC58EH90x, SPC58EH92x, SPC58NH84x, SPC58NH90x, SPC58NH92x

TN1339 - Rev 1 - July 2020 www.st.com


For further information contact your local STMicroelectronics sales office.
TN1339
Overview

1 Overview

SPC58xx MCUs include an onboard temperature sensor that monitors device temperature and delivers two
analog outputs signals and three digital output signals. The analog outputs consist of two voltage signals which
vary linearly with the internal junction temperature:
• a voltage signal that is linearly increasing (PTAT: Proportional to absolute temperature)
• a voltage signal that is linearly decreasing (CTAT: Complementary to absolute temperature).
The analog outputs are connected to an input channel of an ADC on the device. The internal junction temperature
must be calculated by software based on the converted temperature values. The three digital outputs, connected
to the PMC module, are used to signal under- and over-temperature operating conditions. These signals notify the
device to take action to appropriately adjust the device temperature in response to an out of specification low or
high temperature operating condition. Calibration parameter values, associated with the temperature threshold
detection feature, are determined and stored in internal flash memory during production testing at the factory.

1.1 Linear temperature sensor (analog output generation)


The temperature sensor outputs two voltage proportional and complementary proportional to the internal junction
temperature of the chip. These analog voltage signals are converted into digital values by an on-chip ADC
(SAR_ADC_12bit_B0). The temperature value is obtained from a linear voltage-temperature relation with
coefficients adjusted by calibration parameters. These are extracted during factory test and programmed into
flash memory.

TN1339 - Rev 1 page 2/9


TN1339
Temperature formula

2 Temperature formula

The Table 2. Calibration constants shows the addresses of the calibration parameters associated to the
temperature sensor in the internal UTEST memory.

Table 2. Calibration constants

Constant Description UTEST Address

P1 Code from the ADC converting PTAT output voltage at 150ºC 0x400004
P2 Code from the ADC converting PTAT output voltage at -40ºC 0x400000
C1 Code from the ADC converting CTAT output voltage at 150ºC 0x400006
C2 Code from the ADC converting CTAT output voltage at -40ºC 0x400002

In the equations below:


• Pn and Cn are the calibration constants described in Table 2. Calibration constants .
• T is the unknown device temperature in ºC
• Px is the code from the ADC converting PTAT output voltage at the temperature T with any ADC reference
voltage Vref
• Cx is the code from the ADC converting CTAT output voltage at the temperature T with the same ADC
reference voltage Vref
• T2 = -40 ºC
• T1 = 150 ºC
The temperature T is calculated as:
T =T2+ (A*(T1-T2))/(A+B)
Where:
A =Px*C2-(Cx*P2)
B =Cx*P1-(Px*C1)
Please, note that it is mandatory to have the same value as the ADC reference while measuring Px and Cx.
The monitoring of on-chip analog signals coming from temperature sensor is managed by the SARADC
SUPERVISOR (SAR_ADC_12bit_B0) through some specific test channels. The Table 3. SAR_ADC analog test
channels for TSENS shows the test channels for temperature sensor.

Table 3. SAR_ADC analog test channels for TSENS

Test channel Description

120 PTAT (Proportional to absolute temperature)


121 CTAT (Complementary to absolute temperature)

After the conversion is performed on a test channel the converted data is stored at two CDR locations at the end
of conversion, first location is the CDR belonging to the test channel on which conversion is performed and
second location is the CDR belonging to internal channel on which test channel is mapped.

TN1339 - Rev 1 page 3/9


TN1339
Example code for temperature calculation

3 Example code for temperature calculation

The C code below is a part of the SPC5Studio temperature sensor component and shows how to calculate the
junction temperature in SPC58xx devices.

int16_t p1,p2,c1,c2;
uint16_t px,cx;
float a,b;
float t1 = (float)150;
float t2 = (float)-40;

/* get calibration constants from flash */


caddress = tsens_config.constants_address;
p2 = *((vuint16_t*)(caddress));
caddress = tsens_config.constants_address + 2UL;
c2 = *((vuint16_t*)(caddress));
caddress = tsens_config.constants_address + 4UL;
p1 = *((vuint16_t*)(caddress));
caddress = tsens_config.constants_address + 6UL;
c1 = *((vuint16_t*)(caddress));

/* get current vbg and tsens values from saradc channels */


cx = saradc_lld_readchannel(tsens_config.saradc_driver, tsens_config.vbg_channel);
px = saradc_lld_readchannel(tsens_config.saradc_driver, tsens_config.tsens_channel);

/*calculate and b values */


a = ((float)px * (float)c2) - ((float)cx*(float)p2);
b= ((float)cx*(float)p1) - ((float)px*(float)c1);

/* calculate temperature */
temperature = t2 + (((t1-t2)*a)/(a+b));

where:

tsens_config.constants_address = 0x00400000
tsens_config.vbg_channel = 121U
tsens_config.tsens_channel = 120U

TN1339 - Rev 1 page 4/9


TN1339
Acronyms and abbreviations

Appendix A Acronyms and abbreviations

Table 4. Acronyms

Abbreviation Complete name

MCU Microcontroller unit


TSENS Temperature sensor
UTEST User test Flash
ADC Analog to digital converter
SARADC Successive approximation register analog to digital converter
PMC Power management controller

TN1339 - Rev 1 page 5/9


TN1339
Reference documents

Appendix B Reference documents


• SPC58xx 32-bit power architecture microcontroller reference manuals.

TN1339 - Rev 1 page 6/9


TN1339

Revision history

Table 5. Document revision history

Date Version Changes

16-Jul-2020 1 Initial release.

TN1339 - Rev 1 page 7/9


TN1339
Contents

Contents
1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2
1.1 Linear temperature sensor (analog output generation) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Temperature formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 Example code for temperature calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Appendix A Acronyms and abbreviations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Appendix B Reference documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8

TN1339 - Rev 1 page 8/9


TN1339

IMPORTANT NOTICE – PLEASE READ CAREFULLY


STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST
products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST
products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of
Purchasers’ products.
No license, express or implied, to any intellectual property right is granted by ST herein.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. For additional information about ST trademarks, please refer to www.st.com/trademarks. All other product or service
names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.
© 2020 STMicroelectronics – All rights reserved

TN1339 - Rev 1 page 9/9

You might also like