This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS570LC4357: On-chip temperature sensor HalCoGen configuration

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Dear e2e members,

I was trying to repear the junction temperature sensor exercise by following , or the related thread can be found here.

Just have few questions that stopped me from getting the reading:

  1. the new HalCoGen enables the temperature sensor 1, 2, 3 with respective check-box, do I still need tick the PINMMR 174[24] to low?
  2. if the above answer is yes, where can I find this PINMMR in HalCoGen?

Thanks in advance.

I am using CCS 9.1.0, HalCoGen 04.07.01

  • In the Technical Reference Manual, I have found 

    PINMMR174 with address offset of 

    3C4h for temperature sensor 1 and 2

    3C8h for temperature sensor 3.

    But I can't find the input, output table for this PINMMR174, so I need some guidance to point out the link between

    PINMMR to the correct link in HalCoGen config pages.

  • Hello,

    When you select Enable Temp Sensor n, HALCoGen generates:
    PINMUX_TEMPn_ENABLE(ON);  in HL_pinmux.c (  muxInit() function ).
    PINMUX_TEMPn_ENABLE(state) is defined in HL_pinmux.c for TEMP3 to be:

    #define PINMUX_TEMP3_ENABLE(state)      \
                (pinMuxReg->PINMUX[174] = (pinMuxReg->PINMUX[174] & PINMUX_TEMP3_ENABLE_MASK) | (PINMUX_TEMP3_ENABLE_##state))

    then from HL_pinmux.h:
    #define PINMUX_TEMP3_ENABLE_MASK               (~(uint32)((uint32)0xFFU << PINMUX_TEMP3_ENABLE_SHIFT))
    and
    #define PINMUX_TEMP1_ENABLE_ON                                      ((uint32)((uint32)0x2U <<  PINMUX_TEMP1_ENABLE_SHIFT))

    In the same manner other sensors are enabled.

  • Hi Miro

    I can see the first line about MASK exactly the same as you mentioned. 

    #define PINMUX_TEMP3_ENABLE_MASK               (~(uint32)((uint32)0xFFU << PINMUX_TEMP3_ENABLE_SHIFT))

    For the second line, I see not only ON but also OFF, as in the pic below, should I do something about this ? remove the OFF lines?

  • Hello,

    These are different defines. You should not remove them.

    Which define will be used depends on:
    PINMUX_TEMPn_ENABLE(ON);
    or
    PINMUX_TEMPn_ENABLE(OFF);

    Let's, for example, take this define:

    #define PINMUX_TEMP3_ENABLE(state)      \
                (pinMuxReg->PINMUX[174] = (pinMuxReg->PINMUX[174] & PINMUX_TEMP3_ENABLE_MASK) | (PINMUX_TEMP3_ENABLE_##state))       

    If in your code you use
    PINMUX_TEMP3_ENABLE(ON) then PINMUX_TEMP3_ENABLE_##state from the above define will be replaced with PINMUX_TEMP3_ENABLE_ON

  • Hi Miro

    Sorry I messed up with the header file. Now in my  .c file, it is the same as you mentioned.

    So, do I need to replace the last "_##state"  to "_ON" ?

  • Hello,

    No, the  preprocessor will do this because you have PINMUX_TEMPn_ENABLE(ON) macro defined.

    ##state will be changed to ON by preprocessor.

  • Hi Miro

    So, if the PINMUX_TEMPn_ENABLE(ON) macro has been defined,Do I need to configure the Decode (pin number and boolean value) for temperature sensor selection, according to the application note below ?

  • Hello,

    If you take a look at HALCoGen generated code ( HL_pinmux.c file ) at the end of  the muxInit(), when all three sensors are enabled from HALCoGen you will find the following code (comments are added by me):

        pinMuxReg->PINMUX[174] &= 0XFEFFFFFFU; // This will set PINMMR174[24] to 0

        PINMUX_TEMP1_ENABLE(ON); //sets PINMMR173 bit 16 and bit 17
        PINMUX_TEMP2_ENABLE(ON); //Sets PINMMR173 bit 24 and bit 25
        PINMUX_TEMP3_ENABLE(ON); //PINMMR174[0]=0 and PINMMR174[1]=1

    You should set AD1CHSEL and AD2CHSEL registers from ADC1 and ADC2 tab.

  • Hi Miro

    I saw in the application note and also other people asked, in this sample, temperature sensor 3 is used, which requires ADC2 group 1 pin activation.

    Because I cannot find Enable Pin 30 on ADC2 Group 1  in HalCoGen.

    Is this AD2CHNSEL(30) = 1 achieved by PINMUX_TEMP3_ENABLE(ON); //PINMMR174[0]=0 and PINMMR174[1]=1 ? Otherwise, could you tell me how to find the AD2CHNSEL(30) pin selection ?

    Also another funny fact is the JunctionTemp read from my thermistor_read() is only 210 Kelvin, which is - 60 degree C, I am using the datasheet to define as MAX_JUNCTION_TEMP 150 , am I missing something from this sample application ?

    Thanks a lot for help.

  • Hello,

    In thermistor_read(), AD2CHNSEL(30) is set to 1 using this: adcreg->GxSEL[1U] = 0x40000000;

    Actually AD2CHNSEL(30)=1 starts the conversion.
    In thermistor_read() all settings are made by the code in the function. For example:

       /* Enable Temp Sensor */
        pinMuxReg->PINMUX[174] &= 0xFEFFFFFF;

    /* Connect Sensor 3 - Temperature sensor 3's output is connected to AD2IN[30] */
        pinmux_restore = pinMuxReg->PINMUX[174];
        pinMuxReg->PINMUX[174] = (pinMuxReg->PINMUX[174] & 0xfffffffe) | 0x00000002;

  • Hi Miro

    Thanks for explaining, this part is clear to me now.

    I have strage Junction_Temp, after reading  this discussion

    https://e2e.ti.com/support/microcontrollers/hercules/f/312/p/784430/2928881?tisearch=e2e-quicksearch&keymatch=ADC%20junction#2928881

    I want to get my reference voltage .

    Do I need to enable sample discharge, and read from the discharge value, or is there a value or function that I can define in the adc-related c files?

  • Hello,

    In both LaunchPad and HDK, by default reference voltage (ADREFHI) is 3.3V. In the example is assumed reference voltage is 3.3V so no scaling is required if you did not change the reference voltage.

  • Thanks Miro.

    I see in the temperature.c, it is calibrating against temperature sensor 1, is the temperature sensor 1 also needed in the PINMUX panel to be activated ?

    At this moment, I only have temperature sensor 3 configured from the codes.

    #define THERMISTOR_CAL_DATA 0xF0080310 /* OTP Temperature Sensor Data Location */

     

  • Hello,

    The calibration in example code is done for sensor 3.

        OTPdataptr = (OTP_temperature_calibration_data_t *)(THERMISTOR_CAL_DATA + (2 * 0x10));

    The result from the above is: F008 0330

  • Hi Miro

    In theory, no matter temperature sensor 1, or 2 or 3, they should have more or less the same reading right ?

    in my case, I can see a strange reading around 200K from the JunctionTemp, and if I put my fingers on the chip I can see the temp drops around 2 to 5 K.

    So I assume it is read by ADC, just the configuration or I missed somehting.

  • Hello,

    You can use the link in your first post to compare the ADC readings with corresponding temperatures. You should use readings for ADREFHI=3.3V if you did not change the reference voltage.

  • Hi Miro

    Thanks for your suppport.

    I will dig in by myself. If there is something new I find, I will post a new thread.

    :D