I have been using STM32 IDE which incorporates the CUBE MX.
Using the HAL code I am able to read on three pins using a separate ADC for each pin. I have started all the ADC's at the same time and then I poll for completion. I am I correct in thinking these ADC reads should be practically simultaneous (i.e. they all read in at a very similar time)?
Code fragment below. Using a NUCLEO-STM32 F446RE btw.
MX_ADC1_Init();
MX_ADC2_Init();
MX_ADC3_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
static int flip,sysclk=0,old_sysclk=0,adc1,adc2,adc3;//adc3_0,adc3_1,adc3_2, adc_pstat0,
int adc_pstat1, adc_pstat2, adc_pstat3;
flip ^= 1;
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_0/*|GPIO_PIN_2|GPIO_PIN_6*/, flip);
HAL_ADC_Start(&hadc3);
HAL_ADC_Start(&hadc2);
HAL_ADC_Start(&hadc1);
adc_pstat1 = HAL_ADC_PollForConversion(&hadc1, 10);
adc_pstat3 = HAL_ADC_PollForConversion(&hadc3, 10); // should already be done!
adc_pstat2 = HAL_ADC_PollForConversion(&hadc2, 10); // should already be done!
adc3 = HAL_ADC_GetValue(&hadc3);
adc2 = HAL_ADC_GetValue(&hadc2);
adc1 = HAL_ADC_GetValue(&hadc1);
if (adc_pstat2 ||adc_pstat3)
asm("\t nop");
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
sysclk = HAL_GetTick();
if ( (sysclk - 1000) > old_sysclk ){
//printf("nucleo F446 0x%X adc3_0 0x%X adc3_1 0x%X adc3_2 0x%X\n",sysclk,adc3_0,adc3_1,adc3_2);
printf("|->nucleo F446 sysclk=0x%X adc1=0x%X adc2=0x%X adc3=0x%X\n",sysclk,adc1,adc2,adc3);
old_sysclk = sysclk;
}
}
/* USER CODE END 3 */
}
HAL_ADC_Start
. So if your CPU doesn't run at maximum frequency, say a few MHz to save power, the delay might very well be several ms, which is not negligeable at all in some applications. – Guillaume Petitjean