- Notifications
You must be signed in to change notification settings - Fork1k
HardwareTimer: Fix assert failed when using TIMER_OUTPUT_COMPARE#1247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
After implementation of:stm32duino/Arduino_Core_STM32#1247it is better to use TIMER_DISABLED instead of TIMER_OUTPUT_COMPAREEven if TIMER_OUTPUT_COMPARE has been kept for compatibilityreason and is still working.Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
After implementation of:stm32duino/Arduino_Core_STM32#1247it is better to use TIMER_DISABLED instead of TIMER_OUTPUT_COMPAREEven if TIMER_OUTPUT_COMPARE has been kept for compatibilityreason and is still working.Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
When assert is activated there may be assert failed, speciallywhen using Tone or Servo with TIM6 or TIM7."assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));"This is due to the fact that when using timer instances withoutoutput (like TIM6 and TIM7 specially used for Tone and Servo)in TIMER_OUTPUT_COMPARE mode, the API setMode() requires a channel,even if it is not used.This was made like this to simplify the HardwareTimer driver,and there is no functional issue, but as there is an assert failedreported when assert is activated, this should be fixed.TIMER_OUTPUT_COMPARE becomes obsolete, but kept for compatibilityreason.When only timing configuration is needed, no need to set mode,just keep the default TIMER_DISABLED.Fixesstm32duino#1244Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
09b074b to3e313f9Compare@ghent360 fix is there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
Due to GH Action issue (resolved now) some of the checks are failed anyway it is ok. |
After implementation of:stm32duino/Arduino_Core_STM32#1247it is better to use TIMER_DISABLED instead of TIMER_OUTPUT_COMPAREEven if TIMER_OUTPUT_COMPARE has been kept for compatibilityreason and is still working.Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
With introduction of PRstm32duino/Arduino_Core_STM32#1247Usage of TIMER_OUTPUT_COMPARE becomes obsolete.Note: removing setMode(1, TIMER_OUTPUT_COMPARE)also works before PR #1247.Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
VitorBoss commentedJun 11, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Sorry to send a message here, I've tried to do it on the forum but couldn't login, I won't open a issue without confirming it first. On v1.9.0 it works flawlessly, on 2.0.0 it don't work at all, I tried this: It refuses to work with channels, if I remove the channel number I got timer interrupts, what am I missing? |
Hi@VitorBoss, you are right, the behavior has been changed/improved thanks to this PR: Alternatively you can configure the timer with channel configuration, |
First, thank you for the reply. If I understood you right is just a matter of replacing the Please add this to the documentation, I was trying to make it work for a week looking on the wiki |
Using Using 2 channel may be interesting only if you wanted to have the same frequency for both callbacks, AND you want a specific delay between both callback. If it is what you wanted to do, it is necessary to specify both pulse duration (the delta between both will determined the delay between both callbacks). |
VitorBoss commentedJun 11, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The use case here is an engine management system, each channel do 2 independent PWM wave form with independent frequency settings, the period isn't the same. Thank you for clarify my doubts. |
uzi18 commentedJun 11, 2021
@valeros do you have more info about this project? |
1 timer = 1 period, so you need 2 timers
So totally there are 4 PWM wave form? You can have a look at examplehttps://github.com/stm32duino/STM32Examples/tree/master/examples/Peripherals/HardwareTimer/PWM_FullConfiguration Also as stated in wiki:https://github.com/stm32duino/wiki/wiki/HardwareTimer-library
So I strongly suggest you to read Reference Manual, chapter relative to TIMx |
Sorry, I won't clear, each channel do 2 software PWM, even with same timer period the code uses interrupts to trigger the PWM period( The only problem I had with latest release was the compatibility with I know you are busy, if you have a time check out the projecthttps://github.com/noisymime/speeduino |
Summary
HardwareTimer: Fix assert failed when using TIMER_OUTPUT_COMPARE
When assert is activated there may be assert failed, specially
when using Tone or Servo with TIM6 or TIM7.
"assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));"
This is due to the fact that when using timer instances without
output (like TIM6 and TIM7 specially used for Tone and Servo)
in TIMER_OUTPUT_COMPARE mode, the API setMode() requires a channel,
even if it is not used.
This was made like this to simplify the HardwareTimer driver,
and there is no functional issue, but as there is an assert failed
reported when assert is activated, this should be fixed.
TIMER_OUTPUT_COMPARE becomes obsolete, but kept for compatibility
reason.
When only timing configuration is needed, no need to set mode,
just keep the default TIMER_DISABLED.
Validation
Test passed:
Fixes#1244