Skip to main content
Visitor II
June 2, 2024
Solved

Can input capture on one timer be triggered by output capture events on an other timer on STM32G4?

  • June 2, 2024
  • 2 replies
  • 1328 views

I'm using CubeIDE and I want to have an output compare event on TIM1 CH1 trigger an input capture event on TIM8. It doesn’t seem like there is a way to do this with normal timer functions and CubeIDE. Is it possible if I work outside CubeIDE?

As a backup, I believe I can also use a DMA transfer triggered by TIM1 CH1 output compare to save TIM8->CNT to memory. Is this a viable solution?

    This topic has been closed for replies.
    Best answer by Michal Dudka

    If I remember correctly, the only "regular" way is the one described by Waclawek.Jan. You can use DMA to read CNT register, but you have to count with some jitter. It can be few ticks (of core clock), but in case another DMA channels running it can be more. If you do not need "single tick" precision, then it is viable.

    But you can also start another timer synchronously with TIM8 and perform capture on it.

    2 replies

    Super User
    June 2, 2024

    > I want to have an output compare event on TIM1 CH1 trigger an input capture event on TIM8.

    In TIM1_CR2.MMS, select OC1REF as TRGO source. In TIM8_SMCR.TS, select  appropriate ITR value for TIM1 to be TIM8's TRGI. In TIM8_CCMRx.CCxS set to 0b11 for TRC to be the capture trigger source.

    JW

    KHarb.1Author
    Visitor II
    June 2, 2024

    I forgot to mention that TIM8 is being reset via ITR9 from TIM20, so the trigger is already in use.  If there isn't another way, I'm back to attempting the DMA implementation above.

     

    Graduate II
    June 2, 2024

    If I remember correctly, the only "regular" way is the one described by Waclawek.Jan. You can use DMA to read CNT register, but you have to count with some jitter. It can be few ticks (of core clock), but in case another DMA channels running it can be more. If you do not need "single tick" precision, then it is viable.

    But you can also start another timer synchronously with TIM8 and perform capture on it.

    Super User
    June 2, 2024

    You can also interconnect TIM1_CH1 and TIM8_CH1 externally, using two pins.

    JW