We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e4e6089 commit d290357Copy full SHA for d290357
src/ledc.rs
@@ -470,7 +470,12 @@ mod chip {
470
}
471
472
pub const fn max_duty(&self) -> u32 {
473
- (1 << self.bits()) - 1
+ // when using the maximum resultion, the duty cycle must not exceed 2^N - 1 to avoid timer overflow
474
+ if cfg!(esp32) && self.bits() == 20 || cfg!(not(esp32)) && self.bits() == 14 {
475
+ (1 << self.bits()) - 1
476
+ } else {
477
+ 1 << self.bits()
478
+ }
479
480
481
pub(crate) const fn timer_bits(&self) -> ledc_timer_bit_t {
0 commit comments