cpu/efm32: improve PWM driver - #22665
Queued
basilfx wants to merge 2 commits into
Queued
Conversation
Contributor
Wouldn't it make sense to correct this in this PR too? 🤔 |
Member
Author
I have another PR incoming to clean this up, and for |
crasbe
reviewed
Sep 6, 2026
Center mode is actually supported, but counts from 0 -> TOP -> 0, so the frequency needs to be adjusted for this.
basilfx
force-pushed
the
feature/efm32_pwm_modes
branch
from
September 6, 2026 08:25
93228eb to
5edac95
Compare
crasbe
approved these changes
Sep 6, 2026
crasbe
enabled auto-merge
September 6, 2026 08:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
Trying to fix the real problem on why this driver marks EFM32 as unsupported (the comment is wrong), I stumbled upon two things:
PWM_CENTERis actually supported (counting up-down-up)PWM_RIGHTwas inverted.I guess that me from ten years ago did not understand this.
Testing procedure
I used the
tests/periph/pwmapplication to test this, together with an STK3600 that maps a single PWM channel to the onboard LED. I then used a scope to verify the period and frequency, measured at the onboard LED.Without this PR, you will notice that the onboard led is brighter in
PWM_RIGHTmode, because it is inverted. The scope screenshot for the unfixedPWM_RIGHTshows this.The scope screenshots below will not tell you if left, right or center alignment is working correctly (I don't know how to measure this easily). But it will show you that the frequency and period remains correct (requested 1000 Hz, got ~1500 Hz).
PWM_LEFT @ 25%
PWM_RIGHT (UNFIXED) @ 25%
PWM_RIGHT (FIXED) @ 25%
PWM_CENTER @ 25%
Issues/PRs references
#22651 lead to this.
Declaration of AI-Tools / LLMs usage:
AI-Tools / LLMs that were used are: