Skip to content

Fix LEDC PWM DutyCycle #752

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

Merged
merged 4 commits into from
May 23, 2025
Merged

Fix LEDC PWM DutyCycle #752

merged 4 commits into from
May 23, 2025

Conversation

brentru
Copy link
Member

@brentru brentru commented May 21, 2025

This pull request updates the analogWrite function in src/components/ledc/ws_ledc.cpp to correct the calculation of the duty cycle for 12-bit resolution.

Key change:

  • Updated the duty cycle calculation to use a more precise formula with type casting and floating-point arithmetic, ensuring accurate scaling for 12-bit resolution. The new formula replaces the integer division with floating-point division and casts value to uint32_t for consistency.

@tyeth tyeth marked this pull request as ready for review May 23, 2025 18:57
@tyeth
Copy link
Contributor

tyeth commented May 23, 2025

This works well Brent, I tested on the scope, and confirmed by Tyler.
It was mentioned in Fridays meeting that Tyler's guide needs to ideally include the patched firmware, so I offered to release it instead.

@tyeth tyeth merged commit d0463bf into main May 23, 2025
39 checks passed
@brentru
Copy link
Member Author

brentru commented May 27, 2025

Okay, glad it worked!

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.

2 participants