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.

TMS320F280025C: Temperature sensor doesn't work

Part Number: TMS320F280025C
Other Parts Discussed in Thread: C2000WARE, SYSCONFIG

Tool/software:

Hello.

I am using the temperature sensor on the TMS320F280025C.
My understanding is that the following program loops through the while statement until the AD conversion is complete, then exits the loop when the conversion is finished and starts the calculation.
However, when I debugged the program, it never exited the while loop.
Below is the function that uses the temperature sensor and the settings for the ADC portion in board.c.
Am I overlooking something?

Thank you in advance for your help.

function↓

int getThermalE(SSCMGParametar* aPara){
volatile uint16_t TempE_ADCResult = 0;

ADC_forceMultipleSOC(ADC_2_BASE, ADC_FORCE_SOC0);

while(ADC_getInterruptStatus(ADC_2_BASE, ADC_INT_NUMBER3) == false){
}
ADC_clearInterruptStatus(ADC_2_BASE, ADC_INT_NUMBER3);

TempE_ADCResult = ADC_readResult(ADC_2_RESULT_BASE, ADC_SOC_NUMBER0);
int16_t TempE = ADC_getTemperatureC(TempE_ADCResult, 3.3f);

if(true == ADC_getInterruptOverflowStatus(ADC_2_BASE, ADC_INT_NUMBER3))
{
ADC_clearInterruptOverflowStatus(ADC_2_BASE, ADC_INT_NUMBER3);
ADC_clearInterruptStatus(ADC_2_BASE, ADC_INT_NUMBER3);
}

return TempE;
}

board.c↓

void ADC_2_init(){
//
// ADC Initialization: Write ADC configurations and power up the ADC
//
// Set the analog voltage reference selection and ADC module's offset trims.
// This function sets the analog voltage reference to internal (with the reference voltage of 1.65V or 2.5V) or external for ADC
// which is same as ASysCtl APIs.
//
ADC_setVREF(ADC_2_BASE, ADC_REFERENCE_INTERNAL, ADC_REFERENCE_3_3V);
//
// Configures the analog-to-digital converter module prescaler.
//
ADC_setPrescaler(ADC_2_BASE, ADC_CLK_DIV_2_0);
//
// Sets the timing of the end-of-conversion pulse
//
ADC_setInterruptPulseMode(ADC_2_BASE, ADC_PULSE_END_OF_CONV);
//
// Powers up the analog-to-digital converter core.
//
ADC_enableConverter(ADC_2_BASE);
//
// Delay for 1ms to allow ADC time to power up
//
DEVICE_DELAY_US(5000);
//
// SOC Configuration: Setup ADC EPWM channel and trigger settings
//
// Disables SOC burst mode.
//
ADC_disableBurstMode(ADC_2_BASE);
//
// Sets the priority mode of the SOCs.
//
ADC_setSOCPriority(ADC_2_BASE, ADC_PRI_ALL_ROUND_ROBIN);
//
// Start of Conversion 0 Configuration
//
//
// Configures a start-of-conversion (SOC) in the ADC and its interrupt SOC trigger.
// SOC number : 0
// Trigger : ADC_TRIGGER_SW_ONLY
// Channel : ADC_CH_ADCIN12
// Sample Window : 8 SYSCLK cycles
// Interrupt Trigger: ADC_INT_SOC_TRIGGER_NONE
//
ADC_setupSOC(ADC_2_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN12, 8U);
ADC_setInterruptSOCTrigger(ADC_2_BASE, ADC_SOC_NUMBER0, ADC_INT_SOC_TRIGGER_NONE);
//
// Start of Conversion 1 Configuration
//
//
// Configures a start-of-conversion (SOC) in the ADC and its interrupt SOC trigger.
// SOC number : 1
// Trigger : ADC_TRIGGER_SW_ONLY
// Channel : ADC_CH_ADCIN2
// Sample Window : 8 SYSCLK cycles
// Interrupt Trigger: ADC_INT_SOC_TRIGGER_NONE
//
ADC_setupSOC(ADC_2_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN2, 8U);
ADC_setInterruptSOCTrigger(ADC_2_BASE, ADC_SOC_NUMBER1, ADC_INT_SOC_TRIGGER_NONE);
//
// Start of Conversion 2 Configuration
//
//
// Configures a start-of-conversion (SOC) in the ADC and its interrupt SOC trigger.
// SOC number : 2
// Trigger : ADC_TRIGGER_SW_ONLY
// Channel : ADC_CH_ADCIN4
// Sample Window : 8 SYSCLK cycles
// Interrupt Trigger: ADC_INT_SOC_TRIGGER_NONE
//
ADC_setupSOC(ADC_2_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN4, 8U);
ADC_setInterruptSOCTrigger(ADC_2_BASE, ADC_SOC_NUMBER2, ADC_INT_SOC_TRIGGER_NONE);
//
// Start of Conversion 3 Configuration
//
//
// Configures a start-of-conversion (SOC) in the ADC and its interrupt SOC trigger.
// SOC number : 3
// Trigger : ADC_TRIGGER_SW_ONLY
// Channel : ADC_CH_ADCIN6
// Sample Window : 8 SYSCLK cycles
// Interrupt Trigger: ADC_INT_SOC_TRIGGER_NONE
//
ADC_setupSOC(ADC_2_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN6, 8U);
ADC_setInterruptSOCTrigger(ADC_2_BASE, ADC_SOC_NUMBER3, ADC_INT_SOC_TRIGGER_NONE);
//
// Start of Conversion 4 Configuration
//
//
// Configures a start-of-conversion (SOC) in the ADC and its interrupt SOC trigger.
// SOC number : 4
// Trigger : ADC_TRIGGER_SW_ONLY
// Channel : ADC_CH_ADCIN7
// Sample Window : 8 SYSCLK cycles
// Interrupt Trigger: ADC_INT_SOC_TRIGGER_NONE
//
ADC_setupSOC(ADC_2_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN7, 8U);
ADC_setInterruptSOCTrigger(ADC_2_BASE, ADC_SOC_NUMBER4, ADC_INT_SOC_TRIGGER_NONE);
//
// Start of Conversion 5 Configuration
//
//
// Configures a start-of-conversion (SOC) in the ADC and its interrupt SOC trigger.
// SOC number : 5
// Trigger : ADC_TRIGGER_SW_ONLY
// Channel : ADC_CH_ADCIN8
// Sample Window : 8 SYSCLK cycles
// Interrupt Trigger: ADC_INT_SOC_TRIGGER_NONE
//
ADC_setupSOC(ADC_2_BASE, ADC_SOC_NUMBER5, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN8, 8U);
ADC_setInterruptSOCTrigger(ADC_2_BASE, ADC_SOC_NUMBER5, ADC_INT_SOC_TRIGGER_NONE);
//
// Start of Conversion 6 Configuration
//
//
// Configures a start-of-conversion (SOC) in the ADC and its interrupt SOC trigger.
// SOC number : 6
// Trigger : ADC_TRIGGER_SW_ONLY
// Channel : ADC_CH_ADCIN14
// Sample Window : 8 SYSCLK cycles
// Interrupt Trigger: ADC_INT_SOC_TRIGGER_NONE
//
ADC_setupSOC(ADC_2_BASE, ADC_SOC_NUMBER6, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN14, 8U);
ADC_setInterruptSOCTrigger(ADC_2_BASE, ADC_SOC_NUMBER6, ADC_INT_SOC_TRIGGER_NONE);
//
// Start of Conversion 7 Configuration
//
//
// Configures a start-of-conversion (SOC) in the ADC and its interrupt SOC trigger.
// SOC number : 7
// Trigger : ADC_TRIGGER_SW_ONLY
// Channel : ADC_CH_ADCIN15
// Sample Window : 8 SYSCLK cycles
// Interrupt Trigger: ADC_INT_SOC_TRIGGER_NONE
//
ADC_setupSOC(ADC_2_BASE, ADC_SOC_NUMBER7, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN15, 8U);
ADC_setInterruptSOCTrigger(ADC_2_BASE, ADC_SOC_NUMBER7, ADC_INT_SOC_TRIGGER_NONE);
//
// ADC Interrupt 1 Configuration
// Source : ADC_SOC_NUMBER0
// Interrupt Source: enabled
// Continuous Mode : disabled
//
//
ADC_setInterruptSource(ADC_2_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
ADC_clearInterruptStatus(ADC_2_BASE, ADC_INT_NUMBER1);
ADC_disableContinuousMode(ADC_2_BASE, ADC_INT_NUMBER1);
ADC_enableInterrupt(ADC_2_BASE, ADC_INT_NUMBER1);
}

  • I am sorry.
    The correct function is below.

    int getThermalE(SSCMGParametar* aPara){
    volatile uint16_t TempE_ADCResult = 0;

    ADC_forceMultipleSOC(ADC_2_BASE, ADC_FORCE_SOC0);

    while(ADC_getInterruptStatus(ADC_2_BASE, ADC_INT_NUMBER1) == false){
    }
    ADC_clearInterruptStatus(ADC_2_BASE, ADC_INT_NUMBER1);

    TempE_ADCResult = ADC_readResult(ADC_2_RESULT_BASE, ADC_SOC_NUMBER0);
    int16_t TempE = ADC_getTemperatureC(TempE_ADCResult, 3.3f);

    if(true == ADC_getInterruptOverflowStatus(ADC_2_BASE, ADC_INT_NUMBER1))
    {
    ADC_clearInterruptOverflowStatus(ADC_2_BASE, ADC_INT_NUMBER1);
    ADC_clearInterruptStatus(ADC_2_BASE, ADC_INT_NUMBER1);
    }

    return TempE;
    }

    The INT Number is set to 1.

  • Hi Hiroki,

    There is an example ex3 of reading temperature in C2000ware. Please refer to it.

    Here is the path:

    [install path] \C2000Ware_5_03_00_00\driverlib\f28002x\examples\adc\ex3

    Thanks,

    Susmitha

  • Hi Susmitha,

    I have already reviewed the sample programs provided and intend to set them up accordingly.
    I believe the only difference from the sample is the use of ADCA in addition to ADCC.
    Is there any possible influence of using two channels?

    Thanks.

  • Both channels are tied internally. You can use either of them. You can quickly change channels on Sysconfig file in project.

    Are the watching the variable in expression window to read temperature?

    Can you please also check if Launchpad is using same VRef  for ADC on the code? Internal or external?

    Finally, it's good to run the example on launchpad to see if it is working or not.

    Thanks,
    Susmitha