cancel
Showing results for 
Search instead for 
Did you mean: 

NTC-Temperature Sensor

hwm
Associate

I used STM32F072C8T6.

ADC - IN0, IN1 set.

An application that measures temperature with an NTC temperature sensor.

스크린샷 2024-02-26 214841.png

 

 

  1. PullUp resistance 10K was connected to Vdd (3.29V) and PA0, PA1..
  2. When the HAL_ADC_Start_DMA function is executed, the voltage of ADC - PA0, PA1 is measured by 3.7 (V).
  3. If the HAL_ADC_Start_DMA function is not run (normal GPIO call setup), 3.29(V) is measured normally.
  4. How can it be higher than the input voltage of 3.29(V)?
  5. Normal ADC not available.

static void MX_ADC_Init(void)

{

/** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)

*/

hadc.Instance = ADC1;

hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;

hadc.Init.Resolution = ADC_RESOLUTION_12B;

hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;

hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;

hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

hadc.Init.LowPowerAutoWait = DISABLE;

hadc.Init.LowPowerAutoPowerOff = DISABLE;

hadc.Init.ContinuousConvMode = ENABLE;

hadc.Init.DiscontinuousConvMode = DISABLE;

hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;

hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

hadc.Init.DMAContinuousRequests = ENABLE;

hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;

if (HAL_ADC_Init(&hadc) != HAL_OK)

{

Error_Handler();

}

 

/** Configure for the selected ADC regular channel to be converted.

*/

sConfig.Channel = ADC_CHANNEL_0;

sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;

sConfig.SamplingTime = ADC_SAMPLETIME_41CYCLES_5;

if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)

{

Error_Handler();

}

 

/** Configure for the selected ADC regular channel to be converted.

*/

sConfig.Channel = ADC_CHANNEL_1;

if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN ADC_Init 2 */

 

/* USER CODE END ADC_Init 2 */

 

}

 

void HW_AdcInit()

{

     while(HAL_ADCEx_Calibration_Start(&hadc) != HAL_OK);

     HAL_ADC_Start_DMA(&hadc, (uint32_t *)adcValue, 2);

}

I want to know the solution.

Thanks.

 

 

 

 

 

2 REPLIES 2
tjaekel
Lead

What is your schematics to connect the NTC sensor?

If you use DMA: is the DMA engine configured and bound to the ADC? Are there INTs enabled, e.g. for DMA complete and the needed INT handlers provided?

Does it work in polling mode?

The NTC sensor is for temperature measurement.

It is the same even if you set it to polling mode.

Thanks.