Question
ADC DMA Multiple channel
Post edited by ST community moderator. In next time please use </> to share a code.
HI, I have Implemented ADC1 - DMA with one channel and ADC2 - DMA with 7 channels and im transmitting data through UART IT. I want to know if this code works usually.
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
if (hadc->Instance == ADC1)
Print_ADC_Values_IT();
if (hadc->Instance == hadc2.Instance)
Print_ADC_Values_IT();
}
hadc2 is workin only when i disable
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&adc1_value, 1);
Here's the overview of my code:
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_ADC2_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
// HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
HAL_ADCEx_Calibration_Start(&hadc2, ADC_SINGLE_ENDED);
// Start ADC1 (1 channel)
// HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&adc1_value, 1);
// Start ADC2 (7 channels)
HAL_ADC_Start_DMA(&hadc2, (uint32_t*)adc2_values, ADC2_CHANNELS);
user code 4
HAL_ADC_ConvCpltCallback
HAL_UART_TxCpltCallback
Print_ADC_Values_IT
