iLLD_TC27xC  1.0
How to use the DTS Interface driver?
Collaboration diagram for How to use the DTS Interface driver?:

DTS gives the die-temperature result which will decoded to standard temperature value. Minimum first two temperature results are to be ignored to get reliable temperature.

In the following sections it will be described, how to integrate the driver into the application framework.

Preparation

Include Files

Include following header file into your C code:

Interrupt Handler Installation

See also How to define Interrupts?

Define priorities for the Interrrupt handler. This is normally done in the Ifx_IntPrioDef.h file:

// priorities are normally defined in Ifx_IntPrioDef.h
#define IFX_INTPRIO_DTS 1

Add the interrupt service routine to your C code which should do the error flag handling:

IFX_INTERRUPT(dtsISR, 0, IFX_INTPRIO_DTS)
{
// DTS finished temperature measurement
uint16 temperatureValue = IfxDts_Dts_getTemperatureValue();
// here we could do something with the value...
// and the DTS can be restarted
}

Finally install the interrupt handler in your initialisation function:

// install interrupt handler
IfxCpu_Irq_installInterruptHandler(&dtsISR, IFX_INTPRIO_DTS);

DTS Module Initialisation

The module initialisation can be done in the same function:

// Get the default configuration
// Adapt the default configuration if required
dtsConfig.isrPriority = IFX_INTPRIO_DTS;
dtsConfig.lowerTemperatureLimit = -35; // SMU alarm if temperature value is below this Celsius value
dtsConfig.upperTemperatureLimit = 150; // SMU alarm if temperature value is above this Celsius value
// Module initialisation

Now, DTS is initialised for starting temperature measurements:

IRQ based measurements

Whenever the interrupt handler is called, a new measurment result is available and could be processed further (e.g. for statistical analysis).

IFX_INTERRUPT(dtsISR, 0, IFX_INTPRIO_DTS)
{
// DTS finished temperature measurement
uint16 temperatureValue = IfxDts_Dts_getTemperatureValue();
// here we could do something with the value...
// and the DTS can be restarted
}

Measurements without IRQs

If no interrupt routine should be used, a new measurement result can be requested the following way:

// start Sensor
// wait until a new result is available
while( IfxDts_Dts_isBusy() );

Alternatively (and this is the normal usage), the DTS could be periodically started from a timer routine, e.g. each mS. The conversion itself takes 100 uS maximum.

Temperature conversion

Following function returns the actual temperature in Celsius: