cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering 3ADC's simultaneously in continuous mode by a timer.

Sgowd.1
Associate II

I have 3 ADCs (ADC1, ADC2, ADC3) configured with 3 different channels for 3 gpio pins to collect the data and all 3 ADC's are triggered simultaneously by TIM1 at the rising edge of the pulse.

It is also configured in the single conversion mode (i.e., at the rising edge of the pulse ADC's are triggered and conversions are made and it is stopped), it is working all good till here. but, when the continuous mode is enabled the ADC values are still triggered but the values getting is completley different (to be precise these values doesnot make any sense and kind of some random junk value).

so my question is, is it possible to configure ADC is continuous conversion mode and also trigger all the 3 ADC's simultaneously at the rising edge of pulse and collect the values after disabling the ADC's at some point?

// ADC's channel and gpio pin initializations. 
 
 
   cADCReadout::sADCInitStruct adc1;
 
         adc1.ADCChannel = ADC1;
 
         adc1.DMAChannel = DMA_Channel_0;
 
         adc1.DMAStream = DMA2_Stream0;                                
 
         adc1.DMATRSFCompleteFlag = DMA_FLAG_TEIF0;
 
 
         cADCReadout::sADCInitStruct adc2;
 
         adc2.ADCChannel = ADC2;
 
         adc2.DMAChannel = DMA_Channel_1;
 
         adc2.DMAStream = DMA2_Stream3;
 
         adc2.DMATRSFCompleteFlag = DMA_FLAG_TEIF0;
 
 
         cADCReadout::sADCInitStruct adc3;
 
         adc3.ADCChannel = ADC3;
 
         adc3.DMAChannel = DMA_Channel_2;
 
         adc3.DMAStream = DMA2_Stream1;
 
         adc3.DMATRSFCompleteFlag = DMA_FLAG_TEIF0;
 
 
         m_oADC1.initialize(adc1);
 
         m_oADC1.addChannel(GPIOA, GPIO_Pin_1,ADC_Channel_1,ADC_SampleTime_112Cycles);
 
 
         m_oADC1.initialize(adc2);
 
         m_oADC1.addChannel(GPIOA, GPIO_Pin_2,ADC_Channel_2,ADC_SampleTime_112Cycles);
 
 
         m_oADC1.initialize(adc3);
 
         m_oADC1.addChannel(GPIOA, GPIO_Pin_3,ADC_Channel_3,ADC_SampleTime_112Cycles);
 
 
//ADC and DMA configuartions
 
void cADCReadout::initialize(sADCInitStruct init)
 
{
 
   m_sInitStruct = init;
 
 
   ADC_InitTypeDef      ADC_InitStructure;
 
   ADC_CommonInitTypeDef ADC_CommonInitStructure;
 
   DMA_InitTypeDef      DMA_InitStructure;
 
 
   //DMA
 
   DMA_InitStructure.DMA_Channel = init.DMAChannel;
 
   DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(init.ADCChannel->DR);
 
   DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)(&m_aRecBuffer);
 
   DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
 
   DMA_InitStructure.DMA_BufferSize = BUFFERSIZE;                              //It was 0 before
 
   DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
 
   DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
 
   DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
 
   DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
 
   DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
 
   DMA_InitStructure.DMA_Priority = DMA_Priority_High;
 
   DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
 
   DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
 
   DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
 
   DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
 
   DMA_Init(init.DMAStream, &DMA_InitStructure);
 
   DMA_Cmd(init.DMAStream, ENABLE);
 
 
   //ADC
 
   ADC_CommonInitStructure.ADC_Mode = ADC_TripleMode_RegSimult;
 
   ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
 
   ADC_CommonInitStructure.ADC_DMAAccessMode =ADC_DMAAccessMode_1;
 
   ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
 
   ADC_CommonInit(&ADC_CommonInitStructure);
 
 
   ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
 
   ADC_InitStructure.ADC_ScanConvMode = ENABLE;                          
 
   ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;                         
 
   ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_Rising ;      
 
   ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;            
 
   ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
 
   ADC_InitStructure.ADC_NbrOfConversion =1;
 
   ADC_Init(init.ADCChannel, &ADC_InitStructure);
 
 
   ADC_EOCOnEachRegularChannelCmd(init.ADCChannel, DISABLE);
 
 
   /* Enable DMA request after last transfer (Single-ADC mode) */
 
   ADC_DMARequestAfterLastTransferCmd(init.ADCChannel, ENABLE);
 
}

10 REPLIES 10
BIlie.1
Associate

Has anyone figured out a solution to this? I am also trying to start multiple ADCs with one timer trigger