@@ -69,13 +69,12 @@ volatile uint8_t timerb2_bit_mask;
6969/*
7070#define USE_TIMERB2 // interferes with PWM on pin 11
7171#define USE_TIMERB0 // interferes with PWM on pin 6
72- #define USE_TIMERA0 // interferes with PWM on pins 5,9,10
7372*/
7473
7574// Can't use TIMERB3 -- used for application time tracking
7675// Leave TIMERA0 to last -- all other timers use its clock
77- const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { TIMERB1 /* , TIMERB2, TIMERB0, TIMERA0 */ };
78- static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { NOT_A_PIN /* , NOT_A_PIN, NOT_A_PIN, NOT_A_PIN */ };
76+ const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { TIMERB1 /* , TIMERB2, TIMERB0 */ };
77+ static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { NOT_A_PIN /* , NOT_A_PIN, NOT_A_PIN */ };
7978
8079
8180static int8_t toneBegin (uint8_t _pin)
@@ -359,6 +358,9 @@ ISR(TCA0_OVF_vect)
359358 // keep pin low after stop (OUTCLR = OUTTGL - 1)
360359 *(timera0_outtgl_reg - 1 ) = timera0_bit_mask;
361360 }
361+
362+ /* Clear flag */
363+ TCA0.SINGLE .INTFLAGS = TCA_SINGLE_OVF_bm;
362364}
363365#endif
364366
@@ -385,6 +387,9 @@ ISR(TCB0_INT_vect)
385387 // keep pin low after stop (OUTCLR = OUTTGL - 1)
386388 *(timerb0_outtgl_reg - 1 ) = timerb0_bit_mask;
387389 }
390+
391+ /* Clear flag */
392+ TCB0.INTFLAGS = TCB_CAPT_bm;
388393}
389394#endif
390395
@@ -403,13 +408,16 @@ ISR(TCB1_INT_vect)
403408
404409 // If no duration (toggle count negative), go on until noTone() call
405410
406- } else { // If toggle count = 0, stop
411+ } else { // If toggle count = 0, stop
407412
408413 disableTimer (TIMERB1);
409414
410415 // keep pin low after stop (OUTCLR = OUTTGL - 1)
411416 *(timerb1_outtgl_reg - 1 ) = timerb1_bit_mask;
412417 }
418+
419+ /* Clear flag */
420+ TCB1.INTFLAGS = TCB_CAPT_bm;
413421}
414422#endif
415423
@@ -428,13 +436,16 @@ ISR(TCB2_INT_vect)
428436
429437 // If no duration (toggle count negative), go on until noTone() call
430438
431- } else { // If toggle count = 0, stop
439+ } else { // If toggle count = 0, stop
432440
433441 disableTimer (TIMERB2);
434442
435443 // keep pin low after stop (OUTCLR = OUTTGL - 1)
436444 *(timerb2_outtgl_reg - 1 ) = timerb2_bit_mask;
437445 }
446+
447+ /* Clear flag */
448+ TCB2.INTFLAGS = TCB_CAPT_bm;
438449}
439450#endif
440451
0 commit comments