2023-10-31 06:46 AM
Hello everyone,
I'm trying to to use TIM2 as interfacing timer to capture 3 hall sensor inputs. I set the TIMx.CR2.TI1S bit to XOR combination and use OC2REF is sent to TIM1 through TRGO as exactly said in RM0008 Interfacing with Hall sensors section. But COM event is not triggered. I think I do something wrong with linking timers. The code is below. Can anyone help me please?
2023-10-31 09:43 AM
Hello @Berkan,
Verify that TIM1 TRGO signal is being generated by TIM2 and received by TIM1
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-10-31 10:23 AM - edited 2023-10-31 11:15 AM
Hello @Sarra.S ,
I am little confused. Shouldn't I generate TRGO by TIM2 and used this trigger as TRGI for TIM1 ?
Thank you..
2023-11-01 07:30 AM - edited 2023-11-01 07:30 AM
Hello again @Berkan,
To program channel 1 in capture mode (tim_TRC selected), you need to write '01' to CC1S bits in CCMR1
Also, according to the RM, you need to program channel 2 in PWM 2 mode by writing '111' to OC2M bits and ‘00’ to CC2S bits.
taking this into consideration,
>>TIM2->CCMR1 |= 0x7003; /*CC1S AS TRC , OC2 PWM MODE 1*/
should be TIM2->CCMR1 |= 0x7001;
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-11-01 07:42 AM
Please make sure that you have configured all the necessary register bits correctly.