cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F042C6U6 ADC Input Problem

Sergen
Associate III

Hello,

I use STM32F042C6U6 processor. I use IN 2, 3 and 4 inputs for ADC, but when I activate channel IN 4 input, there are serious deviations in other ADC values.

My Variable 

uint32_t adc_values[2];

Main Code:

 

 

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_ADC_Init();
  MX_TIM1_Init();
  /* USER CODE BEGIN 2 */
  HAL_ADCEx_Calibration_Start(&hadc);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
      HAL_ADC_Start(&hadc);
      for (int i = 0; i < 2; i++) {
          HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY);
          adc_values[i] = HAL_ADC_GetValue(&hadc);
      }

      HAL_ADC_Stop(&hadc);
      HAL_Delay(150);

      // Burada adc_values[] dizisindeki değerler işlenebilir
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

 

 

My Clock Settings

Sergen_0-1729362040278.png

 

 

0 REPLIES 0