cancel
Showing results for 
Search instead for 
Did you mean: 

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

pgregson1
Associate III
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

1 ACCEPTED SOLUTION

Accepted Solutions
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

View solution in original post

6 REPLIES 6
Posted on October 27, 2017 at 21:54

Yes

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on October 27, 2017 at 21:56

Thank you.

Peter

Posted on October 27, 2017 at 22:02

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

JW

Posted on October 27, 2017 at 22:03

You seem to have identified the primary limitations with respect to the singular counting element. You should be able to capture the phase and trigger on phase with two different channels. Dealing with delta measurements and cycles is more of a challenge, math will no longer be modulo 65536

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on October 27, 2017 at 22:04

I was using STM32CubeMX instead of writing to registers. I will dig up the register values and post them.

Peter

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