Suppress EMI noise on water flow sensor by filtering short pulses

This commit is contained in:
2026-05-06 09:26:14 +02:00
parent d903c2bf52
commit 403517fdb4

View File

@@ -53,6 +53,9 @@ impl<'a> TankSensor<'a> {
let one_wire_bus = OneWire::new(one_wire_pin, false);
pcnt1.set_high_limit(Some(i16::MAX))?;
// Reject pulses shorter than ~12.8 µs (1023 APB cycles @ 80 MHz) to suppress EMI noise
// on the sensor cable. Real flow pulses are in the millisecond range.
pcnt1.set_filter(Some(1023)).unwrap();
let ch0 = &pcnt1.channel0;
ch0.set_edge_signal(flow_sensor.peripheral_input());