Skip to content

Fix LEDC duty-cycle updates - #294

Merged
bjoernQ merged 3 commits into
esp-rs:mainfrom
IsaacDynamo:duty-cycle
Dec 12, 2022
Merged

bjoernQ merged 3 commits into
esp-rs:mainfrom
IsaacDynamo:duty-cycle

Conversation

@IsaacDynamo

Copy link
Copy Markdown
Contributor

Fixes #285.

Added start_duty_without_fade!() and update_channel!() to set_duty!() in order for the new duty-cycle to take effect.

start_duty_without_fade!() is a new macro that configures the fading register. It was found that setting LEDC_DUTY_START_CHn is required in order for the new duty-cycle to take effect. The other fields of the conf1 are also written and configured for no fading.

For cfg(esp32) the update_channel!() macro now takes a speed argument, and will result in a no-op for high speed. Because high speed variant doesn't have the para_up field.

This PR also removes the restriction that set_duty(0) could not be called without error.

Tested on ESP32C3. Builds for ESP32.

@bjoernQ bjoernQ left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@bjoernQ

bjoernQ commented Dec 12, 2022

Copy link
Copy Markdown
Contributor

Checked on all targets

Thanks for the fix!

@bjoernQ
bjoernQ merged commit 68cb35e into esp-rs:main Dec 12, 2022
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.

ESP32C3: set_duty_hw() on ledc::Channel doesn't work

2 participants