2023-05-16 02:23 AM
Hi,
I am working on STM32G474.
I want to read multiple ADC channels (ADC1 , ADC2 and ADC3 all with 4 channels at a time).
I generated interrupt using timer 3 (update event) and reading ADC channels under
/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start_IT(&htim3);
HAL_ADC_Start_IT(&hadc1);
HAL_ADC_Start_IT(&hadc2);
HAL_ADC_Start_IT(&hadc3);
/* USER CODE END 2 */
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
UNUSED(hadc);
adc_val1 = HAL_ADC_GetValue(&hadc1);
//HAL_GPIO_TogglePin(L5_GPIO_Port, L5_Pin);
}
adc_val1 = HAL_ADC_GetValue(&hadc1); will read only 1 channel and 1 ADC. I want to read 4 channels of ADC1 and likewise for ADC2 and ADC3 under same interrupt.
2023-05-16 03:14 AM
Well, there are indeed several instances of the ADC, so that each of these instances can also take a measurement at exactly the same time, which is important, for example, when measuring motor currents for an FOC.
However, the ADC channels are multiplexed per instance, so they are selected for one measurement each. In this respect, you cannot measure on 4 channels at the same time, but only individually after switching.
Does it answer your question?
Regards
/Peter
2023-05-16 03:17 AM
Hello Peter,
could you share some examples for the same.
Regards,
Nikhil