diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 5fa57a77..899bcf41 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs @@ -139,7 +139,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { r.prescaler .write(|w| w.prescaler().bits(config.prescaler as u8)); r.countertop - .write(|w| unsafe { w.countertop().bits(config.top) }); + .write(|w| unsafe { w.countertop().bits(config.max_duty) }); Ok(Self { phantom: PhantomData, @@ -260,7 +260,7 @@ pub struct SequenceConfig { /// Selects up mode or up-and-down mode for the counter pub counter_mode: CounterMode, /// Top value to be compared against buffer values - pub top: u16, + pub max_duty: u16, /// Configuration for PWM_CLK pub prescaler: Prescaler, /// How a sequence is read from RAM and is spread to the compare register @@ -275,7 +275,7 @@ impl Default for SequenceConfig { fn default() -> SequenceConfig { SequenceConfig { counter_mode: CounterMode::Up, - top: 1000, + max_duty: 1000, prescaler: Prescaler::Div16, sequence_load: SequenceLoad::Common, refresh: 0, diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index d02b0c9c..6014c899 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs @@ -91,7 +91,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { let mut config = SequenceConfig::default(); config.prescaler = Prescaler::Div1; // 1 period is 32767 * 1/16mhz = 0.002047938 = 2.047938ms - config.top = 32767; + config.max_duty = 32767; // pwm example is delaying >~3ms before updating duty cycle, our refreshes // happen exactly at 2.047938ms so we need a delay after each value of >~1ms // which for us is ~1-2 periods