Skip to main content
Proteus
Associate II
December 1, 2020
Question

NUCLEO-F030R8 Default ADC Value 1.65V(2035)

  • December 1, 2020
  • 4 replies
  • 1698 views

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);

This topic has been closed for replies.

4 replies

waclawek.jan
Super User
December 1, 2020

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
ProteusAuthor
Associate II
December 1, 2020

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
ProteusAuthor
Associate II
December 1, 2020

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

Ozone
Principal
December 1, 2020

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

Proteus
ProteusAuthor
Associate II
December 1, 2020

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

Deactivate channels are 0V

Proteus
ProteusAuthor
Associate II
December 1, 2020

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,