MSPM0L1304: Temperature sensor read wrong/big value

Part Number: MSPM0L1304

Hi, 


In int main(void), after SYSCFG_DL_init();, I get tempVoltageRef value once for all.

#define TEMP_OFFSET 30U

uint16_t gADCSamples[ADC_SAMPLE_SIZE];

int main(void) {
int16_t  adc_temp_raw, temp_raw
...

  SYSCFG_DL_init();
  tempVoltageRef = (int16_t)(DL_FactoryRegion_getTemperatureVoltage() & 0x0FFF);


Later in while loop, I subtract ADC value for temperature sensor/channel 11 from above tempVoltageRef, and using below equation from manual, I get temperature in Celsius C.

while (1) {

      adc_temp_raw = tempVoltageRef - (int16_t)(gADCSamples[3] & 0x0FFF); // Temperature

      temp_raw = (int16_t)((adc_temp_raw / 8) + (adc_temp_raw / 16) +
                           (adc_temp_raw / 128) + TEMP_OFFSET);

I debug the code, and it read totally wrong and very big value for temperature. Please kindly provide a sample code that works.

 

image.png

Kind Regards

  • Hi M.Z.

    Please double check your sample time, internam temperature sensor requires larger than 10us to be stably sampled.

    B.R.

    Sal

  • Thanks Sal!

    1- Right now, Sample Clock Divider is Divide by 1 and Calculated Sample Clock Frequency is 32MHz and ADC Conversion Period is 781ns, if I increase Sample Clock Divider is Divide by 16 and Calculated Sample Clock Frequency is 2MHz and ADC Conversion Period is 9us. Do you mean this change?

    2- I need to use ADC12's Conversion Mode as sequence, to sample 3 voltages and one temperature sensor. Is it possible to have slow conversion time for temp sensor, and faster for these 3 voltages in Sequence Conversion Mode?

    Kind Regards,

  • Hi M.Z.

    The sample time only take care of the below settings:

    It is 10-bit register:

    Make sure your VAL is not overflow with larger sample time setting.

    10us = 320 * 1/32MHz <1024. There is no need to further divide SAMPCLK.

    I need to use ADC12's Conversion Mode as sequence, to sample 3 voltages and one temperature sensor. Is it possible to have slow conversion time for temp sensor, and faster for these 3 voltages in Sequence Conversion Mode?

    Yes, we have two sample window for user's selection. You can set different value, and pick the larger one for internal temperature sensor only.

    B.R.

    Sal