2013-09-03 04:00 AM
Hi,
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);2013-09-03 04:55 AM
How's CH4 possibly going to route in this scenario?
2013-09-03 05:16 AM
Oh, i missed that! It should be possible to use channel 3 instead of channel 4, right?
2013-09-03 09:26 AM
You might be able to do something with the XOR, but that would be the only path I can see.
2013-09-04 01:56 AM
I achieved to use channel 3 as input to clock signal. The hall sensor for timer 3 should be enabled to do that though. I think it must have something to do with xor gate.
Thanks again clive.2014-06-26 06:11 AM
Hi there
I know that ths post is quite old, but I have to do exactly the same thing, on a stm32f373: I have an input signal on ch3 to capture and need to output a different signal based on the first on ch4.How do I use the XOR/how do enable the hall sensor? :\Please advise me on that!Thank you very much.2014-06-26 08:25 PM
The thread is really about using CH3 as an external clock, clocking the whole timer. You can use CH3 in Input Capture mode without any drama, but not PWM Input mode (duty/period).
Provided the frequency isn't too high, you can catch the CC3 interrupt, and program the values you want into CH4. You likely want to use Toggle mode, and place the edges with advancing values in CCR4. This will however require maximal values for the Period (technically you could have lesser values, but it makes life more difficult perhaps tightening your interrupt deadlines, and requiring MOD operations). What's happening with CH1 and CH2? Motors and Hall Sensors really aren't my thing, so I'll suggest you review/digest the documentation and experiment.