cancel
Showing results for 
Search instead for 
Did you mean: 

How to use triple simultaneous mode with timer as trigger?

yellowtomato
Associate II

***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

0693W00000BZWFHQA5.png0693W00000BZWFRQA5.png0693W00000BZWFqQAP.png0693W00000BZWFvQAP.png0693W00000BZWG5QAP.png0693W00000BZWG0QAP.png

1 REPLY 1
yellowtomato
Associate II

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?