I need to have timer output compare synchronized with timer global interrupt ,they start separately with two lines below



but i see 2us difference between them, what I have to do?

thanks in advance

  • \$\begingroup\$ If you need both timers to track each other, don't use two timers. It is bad practice and a waste of timers. Use one timer. Or are you overflowing on one timer and don't have enough resolution on the other? Or are you running low on in timer interrupts on one timer? \$\endgroup\$ – DKNguyen Jan 13 '20 at 15:43
  • \$\begingroup\$ Why are you using two timers? Most timers have more than 1 channel that can be used and because they use the same reference (they ARE the same timer) then they will already be in sync. \$\endgroup\$ – Christopher Dyer Jan 13 '20 at 16:11
  • \$\begingroup\$ @DKNguyen, I am using one timer (TIM3) and have two function one of them is output compare which toggles a MCU pin and other function is inside interrup which toggles one gpio; but this two gpios are not sychronized \$\endgroup\$ – Mostafa khavanin zadeh Jan 13 '20 at 20:10
  • \$\begingroup\$ @Mostafakhavaninzadeh Do you not have any compare registers leftover that can trigger an interrupt on a count that the "inside interrupt GPIO" can be in? If you don't, you should be able to set an interrupt to fire on EVERY output compare event and in that interrupt check whether the "inside interrupt IO" should be triggered. And the rock bottom way is to not use the output compare at all. Just use interrupts for both and trigger both IO off of different compare registers connected to the same timer. \$\endgroup\$ – DKNguyen Jan 13 '20 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.