2017-10-27 12:49 PM
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
Solved! Go to Solution.
2017-11-02 08:14 AM
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
2017-10-27 12:54 PM
Yes
2017-10-27 02:56 PM
Thank you.
Peter
2017-10-27 03:02 PM
Post the timer's and relevant GPIO/AFIO registers' content.
JW
2017-10-27 03:03 PM
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
2017-10-27 03:04 PM
I was using STM32CubeMX instead of writing to registers. I will dig up the register values and post them.
Peter
2017-11-02 08:14 AM
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