Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

XMC™ Forum Discussions

Not applicable
Hi,

Is there any example or DAVE component how to use the temperature sensor?
0 Likes
11 Replies
Travis
Employee
Employee
First like received
Hi,

For your information that this is a die temperature sensor. Is this the one you are looking for?
0 Likes
Not applicable
Yes, I'm looking example code for TSE.
0 Likes
chismo
Employee
Employee
First like received
Hello,

The XMC Lib for SCU provides some APIs to access the temperature sensor in XMC1000.

An example code to read out the temperature to a variable temp_k is shown below:


/* Enable TSE */
XMC_SCU_StartTempMeasurement();

/* Calculate temperature of the chip in Kelvin */
temp_k = XMC_SCU_CalcTemperature();


Please remember to add the line for the include file:

#include "xmc_scu.h"


Regards,
Min Wei
0 Likes
schee
Employee
Employee
Hello jsmith65,

Attached are examples using the SCU XMC Lib APIs for the temperature sensor. Are they useful for you?

Regards,
Sally
0 Likes
Not applicable
Thanks.

Is it in the newest XMC Peripheral Library? Can I download it?
0 Likes
schee
Employee
Employee
Hello jsmith65,

The examples call the temperature sensor APIs which are part of the newest SCU XMC Lib.

Regards,
Sally
0 Likes
Not applicable
The previous codes don't work on XMC1100 (tried on XMC1100 boot kit, StepAA)
Here is my code, temp_k is always 64(decimal).
Could you send a working code for XMC1100?


#include "XMC1100.h"
#include "GPIO.h"

void main(void)
{
uint32_t temp_C = 0;
uint32_t temp_k = 0;
uint32_t limit = 0;
uint32_t delay = 10000;

/* Initialize port pins to output mode */
P1_5_set_mode(OUTPUT_PP_GP);
P1_5_reset();

/* Enable DTS */
XMC_SCU_StartTempMeasurement();

while(1)
{
/* Calculate temperature of the chip in Kelvin */
temp_k = XMC_SCU_CalcTemperature();

/* Convert temperature to Celcius */
temp_C = temp_k - 273;
if (temp_C > 25)
{
P1_5_toggle();
}
while(--delay);
delay = 10000;
}
return 0;
}



Tried this code on XMC1300 boot kit: hangs up on XMC_SCU_CalcTemperature.
I'm looking for also a formula: how to calculate temp_kelvin from TSE_MON .
0 Likes
User13217
Level 1
Level 1
it still hangs on XMC1300.

Am I missing something here? Seems like the ROM address in the library might be wrong.

FYI both XMC_SCU_CalcTemperature and XMC_SCU_SetTempHighLimit function hang.

EDIT:

For those who may have the same problem, please refer to the XMC1300 Errata.

It is necessary to use an external library function, which should be included from file named
XMC1000_tseRoutine.c. Headers from XMC1000_TSE.h are also useful.
0 Likes
User12775
Level 5
Level 5
First like received
For your information.

0 Likes
User12781
Level 1
Level 1
Using this code:

/* Enable TSE */
XMC_SCU_StartTempMeasurement();

/* Calculate temperature of the chip in Kelvin */
temp_k = XMC_SCU_CalcTemperature();

Using the XMC1400 boot kit the function "XMC_SCU_CalcTemperature()" always returns 393.

Please help!

Joe.
0 Likes
User17916
Level 1
Level 1
I know this question is old, and I am probably wasting my time posting a response, but maybe I can save somebody a little trouble in the future.

The short answer is, that the XMC_CalcTemperature, or any of its derivatives and variants, does not work correctly because it was never fully implemented by Infineon, which is why it is not included in the #defines in XMC1000_RomFunctionTable.h

The slightly longer answer is that the code as it exists in the XMC1400 boot kit hardware requires four parameters that are supposed to be available in the flash starting at address 0x10000f20, but they are missing (all 0xffffffff). As a result, the calculation always returns 393 since it is the maximum value the sensor was supposed to be good for.

The calculation routine starts at address0x539, so you can set a breakpoint to it in the debugger and overwrite the address that it uses for these values to some place in RAM, and experiment with different values (min, max, gain, offset), but these numbers will be different for each device, so there isn't much point.
0 Likes