Repository navigation
Conversation
hrtim_tu_init() stored the up-down counter frequency (twice the switching frequency) in pwm_conf.frequency, which is the switching frequency. Each further init of the same unit doubled the PWM frequency again, until the period fell below the minimum and the driver's assert aborted. Store the switching frequency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 2026
Open
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.
Summary
In up-down mode, each further
initUnit()on the same timing unit doubles its PWM frequency.hrtim_tu_init()stores the counter frequency, twice the switching frequency, inpwm_conf.frequency, and the next init starts from that value.After a few re-inits, the period goes below the minimum and the
assertin_period_ckpsc()aborts (kernel panic). Left-aligned units aren't affected, becausefreq_multis 1. Most applications init each unit once and never see it. We found it in a test firmware that re-initialised the legs at each PWM start.pwm_conf.frequencyis now the switching frequency for up-down units too, ashrtim_change_frequency()already stores it.hrtim_phase_shift_set()already accepts a timing unit at the master frequency or at twice it, so phase shifts still work.Evidence
Test firmware on a Spin (env
STLink):initFixedFrequency(200000),setModulation(PWMA, UpDwn), theninitUnit(PWMA)three times. After each init, the firmware reads TIMA's period register (PERxR); the values were then read over SWD.mainMerge Danger
Door: two-way
One line in the driver. A revert restores the old behaviour.
Blast Radius: up-down re-init
pwm_conf.frequencyof an up-down unit after init now gets the switching frequency, not twice it. In this repository, onlyhrtim_phase_shift_set()reads it, and it accepts both.🤖 Generated with Claude Code