Question
STM32L4 - ADC Mulit Channel Interrupt support
Hey Guys,
I am working with the STM32L476RG Nucleo board (however my custom board has the L462 chip - I am hoping the solution will work for both chips) and I am trying to get multiple channels ADC interrupts to work without success.
My CubeMX setup is as follows:
My Code:
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {
p_value[indx] = HAL_ADC_GetValue(hadc);
indx = (indx + 1) % 2;
if((indx % 2) == 0) {
HAL_ADC_Start_IT(&hadc1);
}
}
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_USART2_UART_Init();
MX_ADC1_Init();
/* USER CODE BEGIN 2 */
HAL_ADC_Start_IT(&hadc1);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_Delay(5);
sprintf(msg, "ADC1: %hu\t\tADC2: %hu\r\n", p_value[0], p_value[1]);
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}I am expecting to see the callback twice for each HAL_ADC_Start_IT() call but for some reason, it only calls it once. I am able to see only the first channel.
Any help is appreciated!
Thanks!
Almog
