From 87a85a37eae721b5b8a46a6776c80c0cb3c7f7c2 Mon Sep 17 00:00:00 2001 From: "K." Date: Mon, 21 Oct 2024 23:02:06 +0500 Subject: [PATCH] Update sigma-delta modulation example --- examples/src/bin/sdm.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/src/bin/sdm.rs b/examples/src/bin/sdm.rs index c79ca8baa80..4d468cd6af6 100644 --- a/examples/src/bin/sdm.rs +++ b/examples/src/bin/sdm.rs @@ -1,4 +1,4 @@ -//! Connect an oscilloscope to an IO pin and see the modulation sine wave. +//! Connect an oscilloscope to an IO pin and see the modulation sawtooth wave. //! //! Also you may connect low-pass filter to SDM output. //! @@ -33,15 +33,17 @@ fn main() -> ! { } } - let mut sdm = Sdm::new(peripherals.GPIO_SD); - let mut sdm_ch = sdm.enable_pin(modulation_pin, 100.kHz()).unwrap(); + let sdm = Sdm::new(peripherals.GPIO_SD); + let sdm_ch = sdm.channel0.connect(modulation_pin, 100.kHz()).unwrap(); let delay = Delay::new(); println!("Sigma-delta modulation is on"); loop { - sdm_ch.set_pulse_density(0); - delay.delay_millis(1500); + for density in -90..90 { + sdm_ch.set_pulse_density(density); + delay.delay_millis(1); + } } }