cancel
Showing results for 
Search instead for 
Did you mean: 

Active ADC with TIM3 not operate

Barbie
Associate II
Posted on November 12, 2012 at 14:40

Hello.

I try to operate ADC3 triger by TIMe CC1 on scan.

TIM3 is working (I test it by use its interrupt).

But I can't get EOC interrupt from the ADC3.

I check that I operate the RCC for both and also allow NVIC for ADC.

I try to use EOCS=1 and 0 but no help.

Here is the setting I did

void ADC_Scan_direct_Config(void)

{

  ADC_InitTypeDef       ADC_InitStructure;

  ADC_CommonInitTypeDef ADC_CommonInitStructure;

  NVIC_InitTypeDef NVIC_InitStructure;

  /* Enable ADC3 clocks ****************************************/

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC, ENABLE);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3, ENABLE);

 

 

     /* Enable the ADC global Interrupt */

  NVIC_InitStructure.NVIC_IRQChannel = ADC_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure); 

  /* ADC Common Init **********************************************************/

  ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;

  ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; // FCLK/2=ADCCLK

  ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;

  ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;

  ADC_CommonInit(&ADC_CommonInitStructure);

  /* ADC3Init ****************************************************************/

  ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;

  ADC_InitStructure.ADC_ScanConvMode = ENABLE;  // Scan conversion ON

  ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; // conversion takes place continuously

  ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_Rising;

  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T3_CC1; // Timer 3 CC1 event as ADC trigger

  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;

  ADC_InitStructure.ADC_NbrOfConversion = 9; // Always scan all channels send by DMA to back buffer

 /* ADC3 init according to general setting*/

  ADC_Init(ADC3, &ADC_InitStructure);

  /* ADC3 regular channel11 configuration (UV SENS)**********************/

  ADC_RegularChannelConfig(ADC3, ADC_Channel_11, 1, ADC_SampleTime_3Cycles);

     /* ADC3 regular channel9 configuration (TEMP SENS)*************************************/

  ADC_RegularChannelConfig(ADC3, ADC_Channel_9, 2, ADC_SampleTime_3Cycles);

     /* ADC3 regular channel8 configuration (PRESSURE SENS)*************************************/

  ADC_RegularChannelConfig(ADC3, ADC_Channel_8, 3, ADC_SampleTime_3Cycles);  

     /* ADC3 regular channel6 configuration (EXT SENSOR 1 IN1)*************************************/

  ADC_RegularChannelConfig(ADC3, ADC_Channel_6, 4, ADC_SampleTime_3Cycles); 

     /* ADC3 regular channel7 configuration (EXT SENSOR 1 IN2)*************************************/

  ADC_RegularChannelConfig(ADC3, ADC_Channel_7, 5, ADC_SampleTime_3Cycles);

      /* ADC3 regular channel4 configuration (EXT SENSOR 2 IN1)*************************************/

  ADC_RegularChannelConfig(ADC3, ADC_Channel_4, 6, ADC_SampleTime_3Cycles);

       /* ADC3 regular channel7 configuration (EXT SENSOR 2 IN2)*************************************/

  ADC_RegularChannelConfig(ADC3, ADC_Channel_7, 7, ADC_SampleTime_3Cycles); 

         /* ADC3 regular channel14 configuration (EXT SENSOR 3 IN1)*************************************/

  ADC_RegularChannelConfig(ADC3, ADC_Channel_14, 8, ADC_SampleTime_3Cycles); 

           /* ADC3 regular channel15 configuration (EXT SENSOR 3 IN2)*************************************/

  ADC_RegularChannelConfig(ADC3, ADC_Channel_15, 9, ADC_SampleTime_3Cycles); 

 

 

 /* By defult write the Light channle as the only channle to sample (change later by application request*/

   /* ADC2 regular channel14 configuration (HUMIDITY SENSOR)*************************************/

  ADC_RegularChannelConfig(ADC2, ADC_Channel_14, 1, ADC_SampleTime_3Cycles);

     /* ADC2 regular channel15 configuration (LIGHT SENSOR)*************************************/

  ADC_RegularChannelConfig(ADC2, ADC_Channel_15, 2, ADC_SampleTime_3Cycles);

       /* ADC2 regular channel6 configuration (EXT SENSOR 0 IN1)*************************************/

  ADC_RegularChannelConfig(ADC2, ADC_Channel_6, 3, ADC_SampleTime_3Cycles);

         /* ADC2 regular channel7 configuration (EXT SENSOR 0 IN2)*************************************/

  ADC_RegularChannelConfig(ADC2, ADC_Channel_7, 4, ADC_SampleTime_3Cycles);

    /* enable DMA operation on ADC results for ADC3 */

    ADC_DMACmd(ADC3, ENABLE);

    /* DMA requests are issued as long as data are converted and DMA=1*/ 

    ADC_DMARequestAfterLastTransferCmd(ADC3, ENABLE);

   

  /*Enables the EOC on each  sequence of regular conversions*/

  ADC_EOCOnEachRegularChannelCmd(ADC3, DISABLE);

     /* enable End Of Conversion interrupt*/

  ADC_ITConfig(ADC3, ADC_IT_EOC, ENABLE);

 

         /* Enable ADC3 */

  ADC_Cmd(ADC3, ENABLE);

What could be the problem?

 

 

 

 

}

#adc-tim-dma
0 REPLIES 0