Reading the internal temperature of S32K388 using TEMPSENSE module

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Reading the internal temperature of S32K388 using TEMPSENSE module

2,799 次查看
punithchandra
Contributor IV

Hi Team,

We are using the S32K388 MCU. We have a developed a piece of code to read the temperature of the MCU using the available TEMPSENSE module of S32K388.

 

The required MCAL modules are configured including the ADC. We have enabled the below marked parameters as per the user manual. We are testing this on S32K388 Evaluation board.

punithchandra_0-1710314515674.png

 


We are having the UART command so that when the user types the command from the serial terminal, the MCU software reads that command and then reads the internal temperature of MCU using the API Adc_TempSenseCalculateTemp and prints the read results.



As the document says, the read value from the above API is in fixed point format. I have converted these values to the floating point value and printed both the values in the serial terminal.

punithchandra_1-1710314515089.png

 

Below is the command log copy (read multiple times continuously). The yellow highlighted values are converted floating point values while the blue ones are the fixed format value read from the above API.

punithchandra_2-1710314515045.png

 

 

I have observed that the read values change drastically, and the values are ranging from 120 degree centigrades to 190 centigrades. And I doubt that the read values are not correct.

 

Could you please check and let us know your opinion on the above values?

 

Also, I checked the result register for the temperature sensor (ADC channel 49) which is ICDR17 and it' s value keeps changing continuously.

Coming to the configuration we have configured one ADC channel where we have connected external temperature sensor and we are enabling the group conversion, wait for the end of conversion notification function for this group, read the result. Once we readout the external temperature sensor value, then call the function Adc_TempSenseGetTemp to get the temperature from the MCU TEMPSENS module. Since the manual says that the above function is a synchronous call which enables the temperature ADC channel 49, start the conversion, wait for the conversion to complete, read the ADC values, calculate the temperature based on the read value, disables the ADC channel 49 we haven't configured the ADC channel 49 separately.

0 项奖励
回复
22 回复数

2,750 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @punithchandra 

I met something similar in the past and it was caused by too short sampling time. It can significantly affect the accuracy. See please the requirement below:

lukaszadrapa_0-1710408245261.png

Regards,

Lukas

0 项奖励
回复

2,743 次查看
punithchandra
Contributor IV

Hi Lukas

Thank you for the answer.

The screenshot above is from the NXP manual?

And as I mentioned above, I haven't configured the TEMPSENSE ADC channel (#49) as the function Adc_TempSenseGetTemp takes care of the conversion in this channel. Do you mean to say the other ADC channel (#41) which I have configured is causing the issue in this tempsense ADC channel?

0 项奖励
回复

2,739 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Attached is a demo project based on RTD_MCAL_3.0.0_P07 version, and the running environment is Tresos_Studio_29.0 and S32DS_3.5.

Password is "nxp".

Regards,

Lukas

0 项奖励
回复

2,652 次查看
punithchandra
Contributor IV

Hi Lukas

I tried increasing the sampling duration and after that I could see the values are mostly stable and I am getting the calculated temperature value of around 177 degree centigrade. As per the data sheet, the ambient temperature of S32K3xx is around -40 to +125 degrees.

So, does 177 degree is a valid value? I mean is it possible that the MCU gets hot to this extent? I am running just the UART example along with the temperature measurement from ADC.

Regards,

Punith Chandra

0 项奖励
回复

2,643 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @punithchandra 

no, 177°C is too much, you should not see such result. Are you sure the calculation is correct?

Regards,

Lukas

0 项奖励
回复

2,632 次查看
punithchandra
Contributor IV

Hi Lucas,

I am reading the values directly from the API Adc_TempSenseGetTemp which will return the temperature value in the fixed point number format. 

punithchandra_0-1711553303143.png


I tried printing the read value and below are the values in fixed point format. 

"Temp in Fixed point format : 0xb55

Temp in Fixed point format : 0xb56

Temp in Fixed point format : 0xb55

Temp in Fixed point format : 0xb55

Temp in Fixed point format : 0xb53

Temp in Fixed point format : 0xb55

Temp in Fixed point format : 0xb55"

The values are equal to approx 181.2 degree in floating point number format. I verified this conversion as well from the online tool Fixed-point-float-point-conversion . This value is when I tried flashing the same code in the other board.

0 项奖励
回复

2,615 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

I have asked AE team for help. I will let you know once I get a feedback from them.

Regards,

Lukas

0 项奖励
回复

2,560 次查看
punithchandra
Contributor IV

Hi Lukas,

Any update on this?

0 项奖励
回复

2,558 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @punithchandra 

I got the response right now. See please below. It's a problem of RTD:

***

I reviewed this case and tested the internal temperature sensor. I used RTD 4.0.0, and it seems that it is a TempSense API problem. The Adc_TempSenseGetTemp() returns an incorrect convert value, but if we calculate as the RM says, we can get the internal die temperature correct:

First, let me show you my RTD environment:

lukaszadrapa_0-1712299624085.png

 

lukaszadrapa_1-1712299624205.png

 

lukaszadrapa_2-1712299624218.png

 

Once the temp API, the VREF, and the channel ADC group are set, We can read the ADC temp sensor Vest:

lukaszadrapa_3-1712299624184.png

 

So as the RM says:

lukaszadrapa_4-1712299624392.png

 

Making the calculation with a 14bit resolution ADC:

VETS = 5687 * (5V/2^14) = 1.7355

we need also the TCA0, TCA1 and TCA2 values:

lukaszadrapa_5-1712299624246.png

 

Those values are in fixed point, so if we make a conversion:

TCA0 = 0x1A4E = 420.875 C

TCA1 = 0x8AFE = -175.875 C

TCA2 = 0x81DE = -29.875 C

Then, we can apply the formula:

lukaszadrapa_6-1712299624508.png

 

TETS = 420.875 + (-175.875 * 1.7355) + (-29.875 * 1.7355^2)  = 25.66 °C

25.66 C will be the correct internal temperature because I also get incorrect higher temperatures with the API, but it seems that is due to the RTD version:

lukaszadrapa_7-1712299624554.png

 

Let me address this issue with the SW team to fix this issue.

0 项奖励
回复

80 次查看
Nikhil143
Contributor I
Hi @lukaszadrapa

i have a doubt in terms of the resolution as mentioned above it 14bit but in the given project you have considered 12 bit which is the correct way and as per the conversion i understood there is an error so is that fixed in the latest build.

please let me know.

Thanks.
Nikhil
0 项奖励
回复

2,552 次查看
punithchandra
Contributor IV

Hi Lukas,

Thank you for the explanation. I want to highlight few observations. 

punithchandra_0-1712311051191.png


The reference voltage supply is 3.3V not 5V. Value 53 in hex is 0x35 which is in fixed point format. Converting it to float point format, it is 3.3V. With the same formulae whatever you have used and the voltage supply of 3.3V will produce almost same result as being generated from the Tempsense API.

Could you recheck once again?

0 项奖励
回复

2,510 次查看
punithchandra
Contributor IV

Hi Lukas,

Is there any update on this?

0 项奖励
回复

2,507 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Sorry, still waiting...

0 项奖励
回复

2,420 次查看
punithchandra
Contributor IV

Hi Lukas,

May I know is there any update on this?

0 项奖励
回复

2,415 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Here's the response:

 

Thanks for the observation. Changing to 5V (0x80):

lukaszadrapa_0-1713241350943.png

 

ADC Value group:

lukaszadrapa_1-1713241350860.png

 

VETS = 5677 * (5V/2^14) = 1.732 V

 

TCAx Values:

lukaszadrapa_2-1713241350867.png

 

 

TCA0 = 0x1A4E = 420.875 C

TCA1 = 0x8AFE = -175.875 C

TCA2 = 0x81DE = -29.875 C

 

So the temperature will be:
TETS = 420.875 + (-175.875 * 1.732) + (-29.875 *1.732^2)  = 26.63 °C

Results are still similar to the ADC Voltage supply reference of 5V.

0 项奖励
回复

2,410 次查看
punithchandra
Contributor IV

Hi Lukas,

Lot of confusion is going on.

 

The design what we have is that the ADC reference voltage and the tempsense module supply voltage is 3.3V. So the read temperature value for these voltage supply values should be the valid values. We cannot change the reference voltage value to 5V.

 

As per the above response, I can see that only the tempsense supply voltage is changed to 5V. While debugging the code I found that if the ADC reference voltage value is more than the tempsense module supply voltage, then only the tempsense supply voltage is used for the calculation of the temperature value. Otherwise, always the ADC reference voltage is used of the calculation.

 

punithchandra_0-1713246163837.png

 

If the above parameter is not changed to 5V, the temperature calculation will consider the ADC reference voltage value as 3.3V for the calculation.

punithchandra_1-1713246951448.png


As per our requirement, both these voltage values should be configured as 3.3V and the read temperature value should be the valid value.

Please give us the analysis why the temperature value is around 180 degree centigrade when the ADC reference voltage as well as the tempsense supply voltage is 3.3V.

Please let us know is it the issue with the RTD package and if yes what would be the timeline to get it fixed?

 

Request you to check this on priority as the ticket is open for more than a month and this is a blocker for us.

0 项奖励
回复

2,305 次查看
punithchandra
Contributor IV

Hi Lukas,

Any update on this?

0 项奖励
回复

2,237 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Sorry, still waiting...

0 项奖励
回复

2,108 次查看
punithchandra
Contributor IV

Hi Lukas,

Any update on this?

0 项奖励
回复

2,064 次查看
punithchandra
Contributor IV

Hi @lukaszadrapa ,

Any update on this?

0 项奖励
回复