Skip to content

Fix stale cached frequency in PWM auto-allocation#33

Merged
cleishm merged 1 commit intomainfrom
fix/pwm-cached-frequency
Mar 31, 2026
Merged

Fix stale cached frequency in PWM auto-allocation#33
cleishm merged 1 commit intomainfrom
fix/pwm-cached-frequency

Conversation

@cleishm
Copy link
Copy Markdown
Owner

@cleishm cleishm commented Mar 31, 2026

Summary

  • Remove cached frequency_hz from timer_state in PWM auto-allocation
  • Read frequency directly from hardware via ledc_get_freq() when matching timers
  • Fixes stale frequency matching after try_set_frequency() or direct ESP-IDF calls

The other cached fields (resolution_bits, clk_source) are retained — they can only change via ledc_timer_config() (i.e. try_configure()), which updates the cache, and no ESP-IDF getter exists to read them back.

The auto-allocating try_start() cached the timer frequency in a static
struct for matching, but try_set_frequency() and external ESP-IDF calls
updated the hardware without updating the cache. Replace the cached
comparison with ledc_get_freq() to always read the actual frequency.
@cleishm cleishm merged commit e69e274 into main Mar 31, 2026
34 checks passed
@cleishm cleishm deleted the fix/pwm-cached-frequency branch March 31, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant