AnsweredAssumed Answered

Triggering ADC from Timer. Does timer output have to be enabled?

Question asked by Jim.L on Jan 4, 2013
Latest reply on Feb 22, 2013 by waclawek.jan

Hi,
I'm using a STM32F103.
My main question is, is there a way to trigger an ADC regular group using a timer output compare channel but without enabling output to the timer channel's physical output pin?
I've been trying to trigger ADC1 with TIM4_CH4, but I have to use the default pin for TIM4_CH4 for I2C1 and I can't remap TIM4_CH4 because that pin is used for external RAM.
I started with the example code posted in "Timer4 trigger for ADC" (Posted: 6/15/2011 4:44 PM) and that works fine.
But, if I remap I2C1 (using the default TIM4_CH4 pin), the timer interferes with the I2C.
And, if I disable the timer's output, (TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Disable), the ADC does not get triggered.
Is it just that you can't trigger an ADC without using the timer's output pin or does it seem like I have something else messed up?
Below is the example code from "Timer4 trigger for ADC".
Thanks.

TIM4_CC4 should be viable (TIMER 4 CHANNEL 4)
You'll need to program ADC1->CR2, with EXTSEL[2:0] = 5   (101)

  /* TIM4 configuration ------------------------------------------------------*/
  /* Time Base configuration */
  TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
  TIM_TimeBaseStructure.TIM_Period = 0xFF;
  TIM_TimeBaseStructure.TIM_Prescaler = 0x4;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
  /* TIM4 channel4 configuration in PWM mode */
  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 0x7F;
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
  TIM_OC4Init(TIM4, &TIM_OCInitStructure);

..

  /* ADC1 configuration ------------------------------------------------------*/
  ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
  ADC_InitStructure.ADC_ScanConvMode = DISABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T4_CC4;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfChannel = 1;
  ADC_Init(ADC1, &ADC_InitStructure);

Outcomes