diff options
| -rw-r--r-- | embassy-nrf/src/pwm.rs | 6 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence.rs | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 5fa57a77f..899bcf416 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs | |||
| @@ -139,7 +139,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 139 | r.prescaler | 139 | r.prescaler |
| 140 | .write(|w| w.prescaler().bits(config.prescaler as u8)); | 140 | .write(|w| w.prescaler().bits(config.prescaler as u8)); |
| 141 | r.countertop | 141 | r.countertop |
| 142 | .write(|w| unsafe { w.countertop().bits(config.top) }); | 142 | .write(|w| unsafe { w.countertop().bits(config.max_duty) }); |
| 143 | 143 | ||
| 144 | Ok(Self { | 144 | Ok(Self { |
| 145 | phantom: PhantomData, | 145 | phantom: PhantomData, |
| @@ -260,7 +260,7 @@ pub struct SequenceConfig { | |||
| 260 | /// Selects up mode or up-and-down mode for the counter | 260 | /// Selects up mode or up-and-down mode for the counter |
| 261 | pub counter_mode: CounterMode, | 261 | pub counter_mode: CounterMode, |
| 262 | /// Top value to be compared against buffer values | 262 | /// Top value to be compared against buffer values |
| 263 | pub top: u16, | 263 | pub max_duty: u16, |
| 264 | /// Configuration for PWM_CLK | 264 | /// Configuration for PWM_CLK |
| 265 | pub prescaler: Prescaler, | 265 | pub prescaler: Prescaler, |
| 266 | /// How a sequence is read from RAM and is spread to the compare register | 266 | /// How a sequence is read from RAM and is spread to the compare register |
| @@ -275,7 +275,7 @@ impl Default for SequenceConfig { | |||
| 275 | fn default() -> SequenceConfig { | 275 | fn default() -> SequenceConfig { |
| 276 | SequenceConfig { | 276 | SequenceConfig { |
| 277 | counter_mode: CounterMode::Up, | 277 | counter_mode: CounterMode::Up, |
| 278 | top: 1000, | 278 | max_duty: 1000, |
| 279 | prescaler: Prescaler::Div16, | 279 | prescaler: Prescaler::Div16, |
| 280 | sequence_load: SequenceLoad::Common, | 280 | sequence_load: SequenceLoad::Common, |
| 281 | refresh: 0, | 281 | refresh: 0, |
diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index d02b0c9c5..6014c8994 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) { | |||
| 91 | let mut config = SequenceConfig::default(); | 91 | let mut config = SequenceConfig::default(); |
| 92 | config.prescaler = Prescaler::Div1; | 92 | config.prescaler = Prescaler::Div1; |
| 93 | // 1 period is 32767 * 1/16mhz = 0.002047938 = 2.047938ms | 93 | // 1 period is 32767 * 1/16mhz = 0.002047938 = 2.047938ms |
| 94 | config.top = 32767; | 94 | config.max_duty = 32767; |
| 95 | // pwm example is delaying >~3ms before updating duty cycle, our refreshes | 95 | // pwm example is delaying >~3ms before updating duty cycle, our refreshes |
| 96 | // happen exactly at 2.047938ms so we need a delay after each value of >~1ms | 96 | // happen exactly at 2.047938ms so we need a delay after each value of >~1ms |
| 97 | // which for us is ~1-2 periods | 97 | // which for us is ~1-2 periods |
