From e46c6f46af5e2565c5d8a7192808825743df1c14 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 11 Nov 2010 23:57:12 -0500 Subject: Fixing bug w/ subsequent calls to tone(). http://code.google.com/p/arduino/issues/detail?id=397 --- cores/arduino/Tone.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cores/arduino/Tone.cpp b/cores/arduino/Tone.cpp index 8bdc5f7..c3910e7 100755 --- a/cores/arduino/Tone.cpp +++ b/cores/arduino/Tone.cpp @@ -533,8 +533,12 @@ ISR(TIMER2_COMPA_vect) } else { - disableTimer(2); - *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop + // need to call noTone() so that the tone_pins[] entry is reset, so the + // timer gets initialized next time we call tone(). + // XXX: this assumes timer 2 is always the first one used. + noTone(tone_pins[0]); +// disableTimer(2); +// *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop } } -- cgit v1.2.3-18-g5258