AnsweredAssumed Answered

External trigger for TIMER 3

Question asked by asecen on Sep 3, 2013
Latest reply on Jun 27, 2014 by Clive One

I have a working piece of code that takes an input signal on tim3_ch2 (pc7) and outputs a pulse on every 390 counts on tim3_ch1 (pc6). However, i need to use tim3_ch4 (pc9) as input pin for clock signal. I tried to replace pc7 with pc9 and TIM_Channel_2; with TIM_Channel_4 in my code, but that did not work. Can you help me please? My code is below.

  TIM_TimeBaseStructure.TIM_Prescaler = 0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseStructure.TIM_Period = TIM3_period;//TimerPeriod;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
     TIM_ETRClockMode1Config(TIM3, TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0);
     // Input Trigger selection 
  TIM_TIxExternalClockConfig(TIM3, TIM_TIxExternalCLK1Source_TI2, TIM_ICPolarity_Rising, 0);
     //TIM_SelectInputTrigger (TIM3, TIM_TS_TI2FP2);
      // Slave Mode selection: Trigger Mode 
  TIM_SelectSlaveMode(TIM3, TIM_SlaveMode_External1);

  TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);

     TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
     TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
     TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
     TIM_ICInitStructure.TIM_ICFilter = 0;
     //TI2_Config(TIM3, TIM_ICPolarity_Rising, TIM_ICSelection_DirectTI , 0x00); 
     TIM_ICInit(TIM3, &TIM_ICInitStructure);
     TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 10;
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
  TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset;

  TIM_OC1Init(TIM3, &TIM_OCInitStructure);