From 52da86ea8f87e0a913325b75c9d5e7c2ce805039 Mon Sep 17 00:00:00 2001 From: Maxint R&D Date: Mon, 25 Dec 2017 13:33:13 +0100 Subject: [PATCH] Bugfix for ATmega 328/168 Tested with Arduino Nano (ATmega 328) --- MmlMusicPWM.cpp | 2 +- MmlMusicPWM.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MmlMusicPWM.cpp b/MmlMusicPWM.cpp index 99a3324..e982eb3 100644 --- a/MmlMusicPWM.cpp +++ b/MmlMusicPWM.cpp @@ -262,7 +262,7 @@ ISR(TIMER2_COMPA_vect) { // Timer interrupt vector. if(!__thisMmlMusicPWM__) return; - if (millis() > _tTim2_time) + if (millis() > __thisMmlMusicPWM__->_tTim2_time) { __thisMmlMusicPWM__->_noToneTim2(); // Check to see if it's time for the note to end. __thisMmlMusicPWM__->_executeCommandTim2(); // execute the next command diff --git a/MmlMusicPWM.h b/MmlMusicPWM.h index 691d67a..120ce7f 100644 --- a/MmlMusicPWM.h +++ b/MmlMusicPWM.h @@ -55,7 +55,7 @@ class MmlMusicPWM : public MmlMusic { volatile uint8_t *_pinMode; // Pin mode. uint8_t _pinMask = 0; // Bitmask for pins volatile uint8_t *_pinOutput; // Output port register for pin. - const int _tTim2_prescale[] = { 2, 16, 64, 128, 256, 512, 2048 }; // Prescaler. + const int _tTim2_prescale[7] = { 2, 16, 64, 128, 256, 512, 2048 }; // Prescaler. #endif private: