2021-05-28 06:38 AM
***update in the comments***
This is what I want to do: Use ADC1, ADC2 and ADC3 each with multiple channels. I want to trigger them with a timer.
Definition of the buffers:
volatile uint32_t gValueArrayADC1[NUMBER_OF_CHANNELS]={11,12};
volatile uint32_t gValueArrayADC2[NUMBER_OF_CHANNELS]={21,22};
volatile uint32_t gValueArrayADC3[NUMBER_OF_CHANNELS]={31,32};
static uint32_t * pADCArray[NUMBER_OF_ADCS]= {&gValueArrayADC1, &gValueArrayADC2, &gValueArrayADC3};
Start of Timer an ADC:
HAL_ADC_Start_DMA(&hadc2, pADCArray[INDEX_ADC_2], 2);
HAL_ADC_Start_DMA(&hadc3, pADCArray[INDEX_ADC_3], 2);
HAL_ADCEx_MultiModeStart_DMA(&hadc1, pADCArray[INDEX_ADC_1], 2);
HAL_TIM_Base_Start(&htim6);
Everything else is just generated by CubeMx. I will attach my config there at the end of the post.
My problem: it's only going into the DMAX_Streamx_IRQHandler of 2 ADCs. I get values, but they do not seem valid to me.
In the HAL user manual UM1786 it says:
"– For devices with several ADCs: ADC multimode conversion with transfer by DMA:
◦ Activate the ADC peripheral (slave) using function HAL_ADC_Start() (conversion start pending ADC master)"
But how does this work with multiple channels and DMA? Do I need to change HAL_ADC_Start_DMA() to HAL_ADC_Start()? If yes, where is my data stored?
edit: added ADC.zip with the whole project
2021-05-28 08:02 AM
Okay I figured that it should be like this:
HAL_ADC_Start(&hadc2);
HAL_ADC_Start(&hadc3);
HAL_ADCEx_MultiModeStart_DMA(&hadc1, &gValueArrayADC1, 6);
the buffer:
volatile uint32_t gValueArrayADC1[10];
How do I know which adc channel is stored at which index in the array?