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.

RTOS/MSP432P401R: TI-RTOS internal temperature sensor example

Part Number: MSP432P401R


Tool/software: TI-RTOS

Is there an example using TI-RTOS on how to read the internal temperature sensor on the MSP432?

I saw the no-rtos 'adc14_single_channel_temperature_sensor' example, but don't know how to convert all those individual setup commands so I can just do a simple call with 'ADC_convert()'.

Thanks.

  • Hello,

     Currently we do not have TI RTOS example.

    So you will have to do something like this:

    /***********************************************************
      Function: adcInit
    */
    static void adcInit(void)
    {
        HwiP_Params adcHwiParams;
    
        HwiP_Params_init(&adcHwiParams);
        adcHwiParams.arg = 0;
        adcHwiParams.priority = ~0;
        adcHwiParams.name = "ADC14";
        adcHwiHandle = HwiP_create(40, &Hwi_adc, &adcHwiParams);
    
        /* Initializing ADC (MCLK/1/1) with temperature sensor routed */
        ADC14_enableModule();
        ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,
                ADC_TEMPSENSEMAP);
    
        /* Configuring GPIO P4.2 (A11) for Analog In */
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4,
                GPIO_PIN2, GPIO_TERTIARY_MODULE_FUNCTION);
    
        /* Configuring ADC Memory (ADC_MEM0 A22 (Temperature Sensor) and
         * ADC_MEM1 A11 in repeat mode).
         */
        ADC14_configureMultiSequenceMode(ADC_MEM0, ADC_MEM1, false);
        ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A22, false);
    
        ADC14_configureConversionMemory(ADC_MEM1, ADC_VREFPOS_INTBUF_VREFNEG_VSS,
                ADC_INPUT_A11, false);
    
        /* Configuring the sample/hold time for TBD */
        ADC14_setSampleHoldTime(ADC_PULSE_WIDTH_192,ADC_PULSE_WIDTH_192);
    
        /* Enabling sample timer in auto iteration mode and interrupts*/
        ADC14_enableSampleTimer(ADC_AUTOMATIC_ITERATION);
    
        /* Enabling the interrupt when a conversion on channel 1 (end of sequence)
         *  is complete and enabling conversions */
        ADC14_enableInterrupt(ADC_INT1);
    
        /* Setting reference voltage to 2.5 and enabling temperature sensor */
        REF_A_enableTempSensor();
        REF_A_setReferenceVoltage(REF_A_VREF2_5V);
        REF_A_enableReferenceVoltage();
    
        /* Grabbing the calibration values */
        cal30 = MAP_SysCtl_getTempCalibrationConstant(SYSCTL_2_5V_REF,
                SYSCTL_30_DEGREES_C);
        cal85 = MAP_SysCtl_getTempCalibrationConstant(SYSCTL_2_5V_REF,
                SYSCTL_85_DEGREES_C);
        calDifference = cal85 - cal30;
    
        HwiP_enableInterrupt(40);
        ADC14_enableConversion();
    }

    And the HWI (I'm using a semaphore to signal a task):

    /***********************************************************
      Function: Hwi_adc
    */
    void Hwi_adc(UArg arg)
    {
        uint64_t status;
    
        status = MAP_ADC14_getEnabledInterruptStatus();
        MAP_ADC14_clearInterruptFlag(status);
    
        if (status & ADC_INT1)
        {
            temperatureReading = ((ADC14_getResult(ADC_MEM0) - cal30) * 55);
            SemaphoreP_post(tempSem);
        }
    }

    Hopefully this helps.

      David

  • Sorry, but this seems over complicated for me just wanting to read the temperature. I don't want an interrupt, I just want to wait until I get the reading just like in the TI-RTOS example (ADC_convert(adc, &adcValue0);). Plus, I already have the adc module initialized (ADC_init();) and am reading ADC0 and ADC1. Wouldn't the above code re-initialize it, is that OK?

    Similarly, I'd also like to read the input voltage, which like the temperature can also be mapped to an adc, correct?
  • Chris,

    Sorry for the inconvenience, it's something that we are working on adding to the TI Drivers for ADC which utilize the TI-RTOS and will hopefully have this a bit easier sooner than later. Just wanted to let you know that we are aware and are working on it :)
  • Hi David,

    I was just wondering why are n't you using Tasks instead of HwiP. As I will be designing a few more tasks for scheduling using Task.h on TI-RTOS, is it feasible using HwiP instead of Tasks for ADC and combining with the rest?
    If I want to the example code given in the TI-RTOS drivers: adcsinglechannel_MSP_EXP432P401R_TI, which uses tasks, can i edit this code to obtain temperature sensor reading? I have been trying a lot, but I am unable to find the driver implementation for this to make changes to obtain temperature sensor data.

    It would be of great help if you could tell me, How can i go about it as I am new to RTOS and I am having a hard time getting this working.

**Attention** This is a public forum