Skip to main content
pgregson1
Associate III
October 27, 2017
Solved

Is it possible to use Timer 3 in input capture mode on channel 1 and output compare mode on channel 3 simultaneously on STM32F103?

  • October 27, 2017
  • 6 replies
  • 2257 views
Posted on October 27, 2017 at 21:49

Hello,

I am using STM32CubeMX to configure the STM32F103C8T.  I want to use Timer 3 in two modes at the same time.  I want Timer 3 channel 1 in input capture direct mode and Timer 3 channel 3 in output compare channel 3 mode.  I know that the prescaler and period vlues will be the same for both timers.  That is not a problem.  I have tried with two timers, each with one of the modes and with identical prescaler and period values, and this seems to work.  However, when I try to use both modes, one in each of channels 1 and 3 on Timer 3, it doesn't seem to work. 

Is it possible to do this?  I have been wrestling with it, reading considerable literature, seeking examples, reading Mastering the STM32, etc. without success.  

A simple 'yes' or 'no' answer would be very helpful.

Best regards,

Peter

    This topic has been closed for replies.
    Best answer by pgregson1
    Posted on November 02, 2017 at 15:14

    Hello Clive One,

    I see from the diagram for the general-purpose timers (in the RM0008 Reference Manual for the STM32F1xx) that each channel has its own capture/compare register.  This is good because I want to capture the time between successive events on channel 1 while simultaneously producing a timebase time tick on channel 3.  The prescaler and period of this timer are selected to produce a roll-over period that is correct for the timebase tick on channel 3 while simultaneously producing a timing resolution sufficient for measuring the time between events on channel 1.  

    Since the two applications are entirely separate,  I don't have to deal any operations that depend on both of them.

    However, your reply prompted me to do a little more digging into both the source code and the reference manual, whereupon it dawned on me that I was looking for a rollover of the timer that was independent of the channel or mode.  As a result, I found HAL_TIM_PeriodElapsedCallback which of course was a solution to my problem.  

    Thank you for your help. It is much appreciated.  Now I just need to find out how I can mark this question as 'closed'.

    Best regards,

    Peter

    6 replies

    Tesla DeLorean
    Guru
    October 27, 2017
    Posted on October 27, 2017 at 21:54

    Yes

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    pgregson1
    pgregson1Author
    Associate III
    October 27, 2017
    Posted on October 27, 2017 at 21:56

    Thank you.

    Peter

    waclawek.jan
    Super User
    October 27, 2017
    Posted on October 27, 2017 at 22:02

    Post the timer's and relevant GPIO/AFIO registers' content.

    JW