Calculate Die Temperature with DieTemp Component in PSoC 4 - KBA229527

Version 1

    Author: RyanZ_36          Version: **

    The code example “ADC_SAR_Seq_DieTemp” integrated in PSoC® Creator™ demonstrates the usage of the Sequencing SAR ADC Component with an injection channel and the Die Temperature Component (DieTemp).  However, depending on the device family, there are differences in the way the correct temperature is obtained.

    PSoC 4100 / 4200 / 4100 BLE / 4200 BLE / 4100M / 4200M / 4200L Families:

    For these devices, the internal Vref is 1.024 V. If Vref of the SAR ADC is not selected as internal 1.024 V, use the adjustment method in the code example to get the correct die temperature value. For details, see the “Functional Description" section of the PSoC 4 DieTemp datasheet.

    PSoC 4100S/4100S Plus Families:

    For these devices, the internal Vref is 1.2 V; therefore, the adjustment method in the code example is not applicable for PSoC4100S / 4100S Plus. See the following approach to get the correct die temperature. The u32DieTempGet(void) function will return the correct die temperature. The function can be called in the main while loop.

     

    int32 u32DieTempGet(void)

        {

          int16 adc_count;

          uint32 u32_regTemp;

          int32 Celsius;

     

    u32_regTemp = CY_GET_REG32(0x403A0000u);

    CY_SET_REG32(0x403A0000u, ((u32_regTemp & 0xFFFFFF00u) | 0x00000040u)); /* Before DieTemp measurement, change ADC Vref connection to internal Vref(1.2-V) */

       

    ADC_EnableInjection(); /* INJ Channel Enable */

    ADC_StartConvert();    /* ADC Convert start */

    while(0u == ADC_IsEndConversion(ADC_RETURN_STATUS_INJ)){}

     

    adc_count = ADC_GetResult16((uint32)INJ_CHN);

    /* DO NOT need adc count adjusted/calibrated, because Vref has been changed to internal vref (1.2-V) */

               

    Celsius = DieTemp_CountsTo_Celsius(adc_count); /* get temp celsius Degree */

                 

    CY_SET_REG32(0x403A0000u, u32_regTemp); /* after measurement, restore original ADC vref connection register */

          return Celsius;

        }

     

    0x403A0000u is the address of the SAR_CTRL register of PSoC 4100S / 4100S Plus. Bits [6:4] of SAR_CTRL is used for ADC Vref connection control. Before DieTemp measurement, change the Vref connection to internal 1.2 V. After the measurement, restore its connection for normal measurement. The register description is documented in PSoC 4100S and PSoC 4100S Plus register TRM.

    Visit Cypress Community or contact Cypress Sales for more details.

     

    Reference Document:

    PSoC 4 Die Temperature

    PSOC 4100S Family PSOC® 4 Registers Technical Reference Manual (TRM)

    PSOC 4100S Plus Family PSOC® 4 Registers Technical Reference Manual (TRM)