cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U575 Temperature Sensor ADC4 calculation

phuocly
Associate II

Hi,

Currently I am trying to measure MCU junction temperature on the STM32U575 via ADC4 TEMPSENSOR channel (CH13). Upon reading the datasheet and reference manual of the chip, I have some questions regarding this implementation.

According to both the datasheet and reference manual, TEMPSENSOR is shared across ADC1 and ADC4 of the chip via internal channels of them (So this means the raw voltage value should be read out and calculated via ADC4 as expected).

The temperature calculation from the reference manual shows that TS_CAL1 and TS_CAL2 are required calibration value and can be readout

phuocly_0-1736237001109.png

However, according to table 16 of the datasheet, the above value are 14-bit raw data acquired by ADC1 (I also tried reading out these values from a few chips and they all exceeded 4095 (12-bit)

phuocly_1-1736237082283.png

Does this mean the above calibration data only used with raw 14-bit measured adc value from ADC1 and cannot be used with ADC4 12-bit (otherwise we have some overflow?) or I might have missed something out from the document?


Appreciate any support and explanation!

Phuoc

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
filipxsikora
Associate III

Hello,

well, the calibration data are in the highest available resolution, so they are usable with the highest available resolution of the ADC.

When you use lower resolution, just lower the resolution of the calibration data as well.

 

constexpr uint16_t TS_CAL1_12B = TS_CAL1 >> 2; //scale 14bits to 12bits
constexpr uint16_t TS_CAL2_12B = TS_CAL2 >> 2; //scale 14bits to 12bits

 

 

View solution in original post

6 REPLIES 6
RLanz.2
Associate III

Hello

I think this article (translated to English) will help you with the conversion required to the calibration factors: https://mcu.eetrend.com/content/2024/100578516.html

filipxsikora
Associate III

Hello,

well, the calibration data are in the highest available resolution, so they are usable with the highest available resolution of the ADC.

When you use lower resolution, just lower the resolution of the calibration data as well.

 

constexpr uint16_t TS_CAL1_12B = TS_CAL1 >> 2; //scale 14bits to 12bits
constexpr uint16_t TS_CAL2_12B = TS_CAL2 >> 2; //scale 14bits to 12bits

 

 

Hi Filip,

That's also what I thought of as well, although this means precision will not be as good as 14-bit anymore. But for temperature changes and in our application setting this is not a big deal.

Thanks a lot for your suggestion!

Hi,

 

Thanks for the nice reference! Often I wonder where can I see topic like this being posted elsewhere than this forum. 

filipxsikora
Associate III

Well, given the fact, that you don't actually know what the measured temeprature is, it is by nature only some temperature inside of the silicon. But you don't know where it actually is. It can be the CPU hotspot, coldspot, some average of multiple temp sensors scattered around the silicon.. it can be "anything".

And with that in mind, it can (and most likely will) vary with the CPU peripherals being used, given their proximity to the temp sensor(s). Obviously most influence has the overall CPU CLK, which increases the power draw and therefore the internal temp.

For that, I think 12 bits is more than enough. If you need more precise temp measurement, you need at least external NTC.

KDJEM.1
ST Employee

Hello @phuocly,

 

Yes ADC4 can measure the temperature sensor output voltage.

But calibration is only done by ADC1.

As ADC1 is 14 bit, you can use TS_CAL value to scale to 12 bit, by doing so you can use data.

As temperature sensor is voltage output, whatever the ADC is used, voltage result should be same.

This is an example:

TS_CAL1 = 0x0EB5 => 3765 = 3.0 * (3765/16384) = 0.689392 V

TS_CAL2 = 0x137E => 4990 = 3.0 * (4990/16384) = 0.913696 V

So you can use this voltage as calibration value for the 12 bit.

Or you can just change the 14bit ADC conversion result to the 12bit ADC equivalent result just moving 2 bits

0x0EB5 = 0b0000 1110 1011 0101 => two bits right shift: 0b0000 0011 1010 1101           LSB 01 is removed. => 0x03AD

0x137E = 0x0001  0011 0111 1110 => two bits right shift: 0b0000 0100 1101 1111 but rounded at 2nd LSB will result 0b0000 0100 1110 0000 => 0x4E0 (if truncated 0x4DF).

 

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.