cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-F030R8 Default ADC Value 1.65V(2035)

Proteus
Associate II

Hello,

When I activate ADC channel I'm getting 2035 value without any connection from ADC channels, I changed several channel

  HAL_ADC_Start(&hadc);
    HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY);
    raw = HAL_ADC_GetValue(&hadc);
		  // Convert to string and print
    sprintf(msg, "%hu\r\n", raw);
    HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);

7 REPLIES 7

That is OK, unconnected ADC input doesn't mean there is 0V on it.

Connect input voltage. Observe required impedance of the voltage source versus sample time, see datasheet.

JW

Proteus
Associate II

I thought there is fail on MCU after I tried same code on F4Disco Board when ADC unconnect I got 0 value

Do you mean float voltage ?

Thanks,

Proteus
Associate II

I pulled down ADC channel with 10K resistor , there is no affect I couldn't find graph on datasheet

Did you check external connections of the associated GPIO pin on the F030 Nucleo board ?

Yes of course , I tried several ADC channels , When I activate channel 1,65V appear on pin

Deactivate channels are 0V

> I pulled down ADC channel with 10K resistor , ...

Connect it directly to GND - if you are sure there are no other external connections.

Any pull-up/pull-down resistor should be less than the recommended ADC input impedance.

I do not trust the Cube/HAL code either.

Did you check the GPIO/ADC register settings, and the raw conversion results ?

Proteus
Associate II

When I connect to ADC VCC or GND Im getting 4035 or 0 values

I checked ADC settings everything seems to be normal

I changed FW package version

static void MX_ADC_Init(void)
{
 
  /* USER CODE BEGIN ADC_Init 0 */
 
  /* USER CODE END ADC_Init 0 */
 
  ADC_ChannelConfTypeDef sConfig = {0};
 
  /* USER CODE BEGIN ADC_Init 1 */
 
  /* USER CODE END ADC_Init 1 */
  /** 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 = DISABLE;
  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_239CYCLES_5;
  if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN ADC_Init 2 */
 
  /* USER CODE END ADC_Init 2 */
 
}

Thanks,