stm32: fix DAC examples
The DAC driver defaults to enabling the channel trigger, but leaves it at the default value of TIM6 TRGO, then performs a software trigger after writing the new output value. We could change the trigger selection to software trigger, but for this example it's simpler to just disable the trigger.
This commit is contained in:
parent
4db63677f6
commit
c83552eadc
@ -14,11 +14,11 @@ async fn main(_spawner: Spawner) -> ! {
|
|||||||
info!("Hello World, dude!");
|
info!("Hello World, dude!");
|
||||||
|
|
||||||
let mut dac = DacCh1::new(p.DAC, NoDma, p.PA4);
|
let mut dac = DacCh1::new(p.DAC, NoDma, p.PA4);
|
||||||
|
unwrap!(dac.set_trigger_enable(false));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for v in 0..=255 {
|
for v in 0..=255 {
|
||||||
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
||||||
dac.trigger();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ fn main() -> ! {
|
|||||||
let p = embassy_stm32::init(config);
|
let p = embassy_stm32::init(config);
|
||||||
|
|
||||||
let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4);
|
let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4);
|
||||||
|
unwrap!(dac.set_trigger_enable(false));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for v in 0..=255 {
|
for v in 0..=255 {
|
||||||
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
||||||
dac.trigger();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@ fn main() -> ! {
|
|||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4);
|
let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4);
|
||||||
|
unwrap!(dac.set_trigger_enable(false));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for v in 0..=255 {
|
for v in 0..=255 {
|
||||||
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
||||||
dac.trigger();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user