AnsweredAssumed Answered

STM32 Nucleo L476 Internal Temperature Sensor

Question asked by Knechter on Jul 20, 2016
Latest reply on Dec 11, 2016 by bauch.aaron.001
Hello,

I'm trying to get the internal temperature sensor to work. But the whole time, the sampled values are too low. If I use that fancy formula from the reference guide, it says there are about 10°C, but believe me, it's not. The sampled value is always about 970 with 1040 calibrated at 30°C. I tried a lot of configurations but now I don't know how to proceed. Maybe someone can see the problem. There is my code:

ADC Config by CubeMX:

ADC_MultiModeTypeDef multimode;
  ADC_ChannelConfTypeDef sConfig;


    /**Common config 
    */
  hadc1.Instance = ADC1;
  hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV8;
  hadc1.Init.Resolution = ADC_RESOLUTION_12B;
  hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
  hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
  hadc1.Init.LowPowerAutoWait = DISABLE;
  hadc1.Init.ContinuousConvMode = DISABLE;
  hadc1.Init.NbrOfConversion = 1;
  hadc1.Init.DiscontinuousConvMode = DISABLE;
  hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIG_T1_CC1;
  hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
  hadc1.Init.DMAContinuousRequests = DISABLE;
  hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  hadc1.Init.OversamplingMode = DISABLE;
  if (HAL_ADC_Init(&hadc1) != HAL_OK)
  {
    Error_Handler();
  }


    /**Configure the ADC multi-mode 
    */
  multimode.Mode = ADC_MODE_INDEPENDENT;
  if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
  {
    Error_Handler();
  }


    /**Configure Regular Channel 
    */
    sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
    sConfig.Rank = 1;
    sConfig.SamplingTime = ADC_SAMPLETIME_12CYCLES_5;
    sConfig.SingleDiff = ADC_SINGLE_ENDED;
    sConfig.OffsetNumber = ADC_OFFSET_NONE;
    sConfig.Offset = 0;
    HAL_ADC_ConfigChannel(&hadc1, &sConfig);

Measuring:

while(HAL_ADC_PollForConversion(&hadc1,10) != HAL_OK);
              temp = (int)HAL_ADC_GetValue(&hadc1);

Thanks;

Outcomes