cancel
Showing results for 
Search instead for 
Did you mean: 

Injected channel trigger not executing

zoe
Associate
Posted on April 24, 2012 at 00:28

Hi, I am using an STM32F103 chip.  I programmed injected channels on ADC1 and ADC2 to trigger off TIM3 when the CC4 flag triggers.  TIM3_IRQHandler interrupt triggers as expected, but even though I have JEOCIE set, ADC1_2_IRQHandler is never entered.  I used similar code to an example supplied by STM and have included it below.  I also tried setting JAUTO to 1 so that the injected channel will automatically trigger off a regular channel conversion and that does work, so I believe the problem lies in my having not programmed the settings between the CC4 event and the injected channel trigger correctly.  I would appreciate any suggestions from the forum.

Thanks.

***Injected channel set up***

// Set SCAN to true since there are a group of regular channels

ADC1->CR1   = ADC_Mode_RegInjecSimult | kBIT_08;//

ADC2->CR1   = ADC_Mode_RegInjecSimult | kBIT_08;//

 

  // Set injected sequencer length

  ADC_InjectedSequencerLengthConfig(ADC1, 1);

  ADC_InjectedSequencerLengthConfig(ADC2, 1);

 

  // Set injected channel configuration

ADC_InjectedChannelConfig(ADC1, ADC_Channel_3, 1, ADC_SampleTime_28Cycles5);

ADC_InjectedChannelConfig(ADC2, ADC_Channel_15, 1, ADC_SampleTime_28Cycles5);

 

  // Set injected external trigger configuration

  ADC_ExternalTrigInjectedConvConfig(ADC1, ADC_ExternalTrigInjecConv_T3_CC4);

  ADC_ExternalTrigInjectedConvConfig(ADC2, ADC_ExternalTrigInjecConv_None);

  // Enable injected external trigger conversion

  ADC_ExternalTrigInjectedConvCmd(ADC1, ENABLE);

  ADC_ExternalTrigInjectedConvCmd(ADC2, ENABLE);

 

  // Enable JEOC interrupt

  ADC_ITConfig(ADC1, ADC_IT_JEOC, ENABLE);

*** Timer trigger set up (note: there is additional timer code not included) ***

TIM_SetAutoreload(TIM3, tim_TimeBase.TIM_Period);

TIM_ARRPreloadConfig(TIM3, ENABLE);

TIM_ITConfig(TIM3, TIM_IT_CC4, ENABLE);

#adc-stm32
4 REPLIES 4
Posted on April 24, 2012 at 01:23

Try

  ADC_AutoInjectedConvCmd(ADCx, ENABLE);

After the ADC_ExternalTrigInjectedConvConfig()'s

Also perhaps

TIM_CtrlPWMOutputs(TIM3, ENABLE);;
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
zoe
Associate
Posted on April 27, 2012 at 15:34

Hi Clive1, thanks for the quick response and the suggestions.  The problem with using ADC_AutoInjectedConvCmd(ADCx, ENABLE); is that you are no longer triggering the injected channels with an external event, they automatically run a conversion every time the regular channels run a conversion. So the frequency at which I collect new information with the injected channels is dependent upon the timing of the regular channels.  Since the regular channels in my system are already being used, I cannot reset their timing and it doesn't fit with when I need this new data.

As for setting the timer to work as a pwm ( I think that is what the other command does), I haven't tried it yet but I am not sure if it will help because the timer interrupt is definitely firing when expected, it is the injected channel with its JSTART and JEOC that are not setting as expected.

raptorhal2
Lead
Posted on April 27, 2012 at 16:13

Have you looked into running the ADCs in independent mode, regular channels on one and injected on the other ? That will require two DMA channels.

Cheers, Hal

raptorhal2
Lead
Posted on April 27, 2012 at 16:18

Have you looked into running the ADCs in independent mode, regular channels on one and injected on the other ? That will require two DMA channels.

Cheers, Hal