2024-10-19 11:21 AM
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