aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cores/arduino/Tone.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/cores/arduino/Tone.cpp b/cores/arduino/Tone.cpp
index 9bb6fe7..eda8cbb 100644
--- a/cores/arduino/Tone.cpp
+++ b/cores/arduino/Tone.cpp
@@ -30,6 +30,7 @@ Version Modified By Date Comments
0006 D Mellis 09/12/29 Replaced objects with functions
0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register
0008 S Kanemoto 12/06/22 Fixed for Leonardo by @maris_HY
+0009 J Reucker 15/04/10 Issue #292 Fixed problems with ATmega8 (thanks to Pete62)
*************************************************/
#include <avr/interrupt.h>
@@ -296,13 +297,13 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
#if defined(TCCR0B)
if (_timer == 0)
{
- TCCR0B = prescalarbits;
+ TCCR0B = (TCCR0B & 0b11111000) | prescalarbits;
}
else
#endif
#if defined(TCCR2B)
{
- TCCR2B = prescalarbits;
+ TCCR2B = (TCCR2B & 0b11111000) | prescalarbits;
}
#else
{
@@ -456,19 +457,19 @@ void disableTimer(uint8_t _timer)
#if defined(TIMSK3)
case 3:
- TIMSK3 = 0;
+ TIMSK3 &= ~(1 << OCIE3A);
break;
#endif
#if defined(TIMSK4)
case 4:
- TIMSK4 = 0;
+ TIMSK4 &= ~(1 << OCIE4A);
break;
#endif
#if defined(TIMSK5)
case 5:
- TIMSK5 = 0;
+ TIMSK5 &= ~(1 << OCIE5A);
break;
#endif
}