Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hardwaretimer): avoid glitch when PWM configuration changed #2572

Merged
merged 4 commits into from
Nov 21, 2024

Conversation

fpistm
Copy link
Member

@fpistm fpistm commented Nov 19, 2024

Fixes #2575

issue is that TIM_OCx_SetConfig() disable unconditionally the N state output (TIM_CCER_CCxNE), preventing to
call setMode() fix the issue and avoid glitch.

Note

This PR include some hardening and enhancement.

  • get API using uint32_t
  • rename TIMER_DISABLED to TIMER_OUTPUT_DISABLED
  • resume depending of channels mode

@fpistm fpistm added the fix 🩹 Bug fix label Nov 19, 2024
@fpistm fpistm added this to the 2.9.0 milestone Nov 19, 2024
As all get API's use error handler if an error occur,
then no need to use int as return type.
Moreover, all HAL API uses uint32_t
for those value. This avoid cast issue.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
to avoid confusion.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Allow to properly set handle state.
Start TIM base only if required.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Fixes stm32duino#2575.

Note that the issue is that TIM_OCx_SetConfig() disable
in unconditionally the N state output (TIM_CCER_CCxNE).

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
@fpistm fpistm changed the title fix(timer): pause the channel before new PWM config fix(hardwaretimer): avoid glitch when PWM configuration changed Nov 21, 2024
@fpistm fpistm added the enhancement New feature or request label Nov 21, 2024
Copy link
Contributor

@ABOSTM ABOSTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fpistm fpistm merged commit 32b6654 into stm32duino:main Nov 21, 2024
24 checks passed
@fpistm fpistm deleted the HT_FIX branch November 21, 2024 16:06
fpistm added a commit to fpistm/STM32Examples that referenced this pull request Nov 21, 2024
TIMER_DISABLED replaced by TIMER_OUTPUT_DISABLED

See stm32duino/Arduino_Core_STM32#2572

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
fpistm added a commit to stm32duino/STM32Examples that referenced this pull request Nov 21, 2024
TIMER_DISABLED replaced by TIMER_OUTPUT_DISABLED

See stm32duino/Arduino_Core_STM32#2572

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix 🩹 Bug fix
Projects
Development

Successfully merging this pull request may close these issues.

HardwareTimer: using setPWM twice with a channel N stop the pwm
2 participants