Skip to content

Commit 16e74f9

Browse files
committed
Update sigma-delta modulation example
1 parent 2ed9564 commit 16e74f9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: examples/src/bin/sdm.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Connect an oscilloscope to an IO pin and see the modulation sine wave.
1+
//! Connect an oscilloscope to an IO pin and see the modulation sawtooth wave.
22
//!
33
//! Also you may connect low-pass filter to SDM output.
44
//!
@@ -33,15 +33,17 @@ fn main() -> ! {
3333
}
3434
}
3535

36-
let mut sdm = Sdm::new(peripherals.GPIO_SD);
37-
let mut sdm_ch = sdm.enable_pin(modulation_pin, 100.kHz()).unwrap();
36+
let sdm = Sdm::new(peripherals.GPIO_SD);
37+
let sdm_ch = sdm.channel0.connect(modulation_pin, 100.kHz()).unwrap();
3838

3939
let delay = Delay::new();
4040

4141
println!("Sigma-delta modulation is on");
4242

4343
loop {
44-
sdm_ch.set_pulse_density(0);
45-
delay.delay_millis(1500);
44+
for density in -90..90 {
45+
sdm_ch.set_pulse_density(density);
46+
delay.delay_millis(1);
47+
}
4648
}
4749
}

0 commit comments

Comments
 (0)