diff --git a/cores/rp2040/Tone.cpp b/cores/rp2040/Tone.cpp index c5b59018..2fde8254 100644 --- a/cores/rp2040/Tone.cpp +++ b/cores/rp2040/Tone.cpp @@ -88,6 +88,7 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration) { newTone->alarm = 0; } } + pio_sm_clear_fifos(newTone->pio, newTone->sm); // Remove any old updates that haven't yet taken effect pio_sm_put_blocking(newTone->pio, newTone->sm, RP2040::usToPIOCycles(us)); pio_sm_set_enabled(newTone->pio, newTone->sm, true); diff --git a/libraries/Servo/src/Servo.cpp b/libraries/Servo/src/Servo.cpp index fd38625b..7c9844e9 100644 --- a/libraries/Servo/src/Servo.cpp +++ b/libraries/Servo/src/Servo.cpp @@ -135,6 +135,7 @@ void Servo::writeMicroseconds(int value) { value = constrain(value, _minUs, _maxUs); _valueUs = value; if (_attached) { + pio_sm_clear_fifos(_pio, _smIdx); // Remove any old updates that haven't yet taken effect pio_sm_put_blocking(_pio, _smIdx, RP2040::usToPIOCycles(value) / 3); } } diff --git a/libraries/rp2040/examples/Siren/Siren.ino b/libraries/rp2040/examples/Siren/Siren.ino index d395a73d..014a7629 100644 --- a/libraries/rp2040/examples/Siren/Siren.ino +++ b/libraries/rp2040/examples/Siren/Siren.ino @@ -7,7 +7,8 @@ void setup() { } void loop() { - for (int i = 100; i < 10000; i += 5) { + for (int i = 100; i < 10000; i += 1) { tone(TONEPIN, i); + delayMicroseconds(20); } }