This is an example that makes me feel like this should be fairly straight forward: https://itp.nyu.edu/physcomp/labs/labs- … n-arduino/
I don’t know enough to confirm compatibility I guess: https://github.com/bhagman/Tone#ugly-details.
I also think I corrected some super basic things I was doing such that I probably wasn’t even including the library. :oops:
In any case, now that I think I’ve figured that out, I’m getting the following when I try to compile:
WARNING: library Tone claims to run on avr architecture(s) and may be incompatible with your current board which runs on apollo3 architecture(s).
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:126:4: error: expected constructor, destructor, or type conversion before '(' token
ISR(TIMER0_COMPA_vect)
^
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:149:4: error: expected constructor, destructor, or type conversion before '(' token
ISR(TIMER1_COMPA_vect)
^
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:171:4: error: expected constructor, destructor, or type conversion before '(' token
ISR(TIMER2_COMPA_vect)
^
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp: In member function 'void Tone::begin(uint8_t)':
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:280:9: error: 'TCCR0A' was not declared in this scope
TCCR0A = 0;
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:281:9: error: 'TCCR0B' was not declared in this scope
TCCR0B = 0;
^~~~~~
In file included from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Interrupts.h:8,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/ArduinoAPI.h:29,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/Arduino.h:17,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/sdk/ArduinoSDK.h:9,
from <command-line>:
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:282:26: error: 'WGM01' was not declared in this scope
bitWrite(TCCR0A, WGM01, 1);
^~~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:282:9: note: in expansion of macro 'bitWrite'
bitWrite(TCCR0A, WGM01, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:283:26: error: 'CS00' was not declared in this scope
bitWrite(TCCR0B, CS00, 1);
^~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:283:9: note: in expansion of macro 'bitWrite'
bitWrite(TCCR0B, CS00, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:283:26: note: suggested alternative: 'B100'
bitWrite(TCCR0B, CS00, 1);
^~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:283:9: note: in expansion of macro 'bitWrite'
bitWrite(TCCR0B, CS00, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:284:46: error: 'digitalPinToPort' was not declared in this scope
timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
^~~~~~~~~~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:284:46: note: suggested alternative: 'digitalPinToInterrupt'
timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
^~~~~~~~~~~~~~~~
digitalPinToInterrupt
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:284:27: error: 'portOutputRegister' was not declared in this scope
timer0_pin_port = portOutputRegister(digitalPinToPort(_pin));
^~~~~~~~~~~~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:285:27: error: 'digitalPinToBitMask' was not declared in this scope
timer0_pin_mask = digitalPinToBitMask(_pin);
^~~~~~~~~~~~~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:285:27: note: suggested alternative: 'digitalPinToInterrupt'
timer0_pin_mask = digitalPinToBitMask(_pin);
^~~~~~~~~~~~~~~~~~~
digitalPinToInterrupt
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:294:9: error: 'TCCR1A' was not declared in this scope
TCCR1A = 0;
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:295:9: error: 'TCCR1B' was not declared in this scope
TCCR1B = 0;
^~~~~~
In file included from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Interrupts.h:8,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/ArduinoAPI.h:29,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/Arduino.h:17,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/sdk/ArduinoSDK.h:9,
from <command-line>:
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:296:26: error: 'WGM12' was not declared in this scope
bitWrite(TCCR1B, WGM12, 1);
^~~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:296:9: note: in expansion of macro 'bitWrite'
bitWrite(TCCR1B, WGM12, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:297:26: error: 'CS10' was not declared in this scope
bitWrite(TCCR1B, CS10, 1);
^~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:297:9: note: in expansion of macro 'bitWrite'
bitWrite(TCCR1B, CS10, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:297:26: note: suggested alternative: 'B110'
bitWrite(TCCR1B, CS10, 1);
^~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:297:9: note: in expansion of macro 'bitWrite'
bitWrite(TCCR1B, CS10, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:306:9: error: 'TCCR2A' was not declared in this scope
TCCR2A = 0;
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:307:9: error: 'TCCR2B' was not declared in this scope
TCCR2B = 0;
^~~~~~
In file included from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Interrupts.h:8,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/ArduinoAPI.h:29,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/Arduino.h:17,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/sdk/ArduinoSDK.h:9,
from <command-line>:
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:308:26: error: 'WGM21' was not declared in this scope
bitWrite(TCCR2A, WGM21, 1);
^~~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:308:9: note: in expansion of macro 'bitWrite'
bitWrite(TCCR2A, WGM21, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:309:26: error: 'CS20' was not declared in this scope
bitWrite(TCCR2B, CS20, 1);
^~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:309:9: note: in expansion of macro 'bitWrite'
bitWrite(TCCR2B, CS20, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:309:26: note: suggested alternative: '._20'
bitWrite(TCCR2B, CS20, 1);
^~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:309:9: note: in expansion of macro 'bitWrite'
bitWrite(TCCR2B, CS20, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp: In member function 'void Tone::play(uint16_t, uint32_t)':
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:382:13: error: 'F_CPU' was not declared in this scope
ocr = F_CPU / frequency / 2 - 1;
^~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:382:13: note: suggested alternative: 'FPU'
ocr = F_CPU / frequency / 2 - 1;
^~~~~
FPU
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:422:9: error: 'TCCR0B' was not declared in this scope
TCCR0B = (TCCR0B & 0b11111000) | prescalarbits;
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:425:9: error: 'TCCR2B' was not declared in this scope
TCCR2B = (TCCR2B & 0b11111000) | prescalarbits;
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:430:13: error: 'F_CPU' was not declared in this scope
ocr = F_CPU / frequency / 2 - 1;
^~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:430:13: note: suggested alternative: 'FPU'
ocr = F_CPU / frequency / 2 - 1;
^~~~~
FPU
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:440:9: error: 'TCCR1B' was not declared in this scope
TCCR1B = (TCCR1B & 0b11111000) | prescalarbits;
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:471:9: error: 'OCR0A' was not declared in this scope
OCR0A = ocr;
^~~~~
In file included from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Interrupts.h:8,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/ArduinoAPI.h:29,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/Arduino.h:17,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/sdk/ArduinoSDK.h:9,
from <command-line>:
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:473:18: error: 'TIMSK0' was not declared in this scope
bitWrite(TIMSK0, OCIE0A, 1);
^~~~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:30: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:473:9: note: in expansion of macro 'bitWrite'
bitWrite(TIMSK0, OCIE0A, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:473:26: error: 'OCIE0A' was not declared in this scope
bitWrite(TIMSK0, OCIE0A, 1);
^~~~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:473:9: note: in expansion of macro 'bitWrite'
bitWrite(TIMSK0, OCIE0A, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:478:9: error: 'OCR1A' was not declared in this scope
OCR1A = ocr;
^~~~~
In file included from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Interrupts.h:8,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/ArduinoAPI.h:29,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/Arduino.h:17,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/sdk/ArduinoSDK.h:9,
from <command-line>:
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:480:18: error: 'TIMSK1' was not declared in this scope
bitWrite(TIMSK1, OCIE1A, 1);
^~~~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:30: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:480:9: note: in expansion of macro 'bitWrite'
bitWrite(TIMSK1, OCIE1A, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:480:26: error: 'OCIE1A' was not declared in this scope
bitWrite(TIMSK1, OCIE1A, 1);
^~~~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:480:9: note: in expansion of macro 'bitWrite'
bitWrite(TIMSK1, OCIE1A, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:483:9: error: 'OCR2A' was not declared in this scope
OCR2A = ocr;
^~~~~
In file included from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Interrupts.h:8,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/ArduinoAPI.h:29,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/Arduino.h:17,
from /Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/sdk/ArduinoSDK.h:9,
from <command-line>:
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:485:18: error: 'TIMSK2' was not declared in this scope
bitWrite(TIMSK2, OCIE2A, 1);
^~~~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:30: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:485:9: note: in expansion of macro 'bitWrite'
bitWrite(TIMSK2, OCIE2A, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:485:26: error: 'OCIE2A' was not declared in this scope
bitWrite(TIMSK2, OCIE2A, 1);
^~~~~~
/Users/mjwarne/Library/Arduino15/packages/SparkFun/hardware/apollo3/2.2.1/cores/arduino/mbed-bridge/core-api/api/Common.h:65:49: note: in definition of macro 'bitSet'
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
^~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:485:9: note: in expansion of macro 'bitWrite'
bitWrite(TIMSK2, OCIE2A, 1);
^~~~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp: In member function 'void Tone::stop()':
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:517:7: error: 'TIMSK0' was not declared in this scope
TIMSK0 &= ~(1 << OCIE0A);
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:517:24: error: 'OCIE0A' was not declared in this scope
TIMSK0 &= ~(1 << OCIE0A);
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:521:7: error: 'TIMSK1' was not declared in this scope
TIMSK1 &= ~(1 << OCIE1A);
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:521:24: error: 'OCIE1A' was not declared in this scope
TIMSK1 &= ~(1 << OCIE1A);
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:524:7: error: 'TIMSK2' was not declared in this scope
TIMSK2 &= ~(1 << OCIE2A);
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:524:24: error: 'OCIE2A' was not declared in this scope
TIMSK2 &= ~(1 << OCIE2A);
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp: In member function 'bool Tone::isPlaying()':
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:552:22: error: 'TIMSK0' was not declared in this scope
returnvalue = (TIMSK0 & (1 << OCIE0A));
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:552:37: error: 'OCIE0A' was not declared in this scope
returnvalue = (TIMSK0 & (1 << OCIE0A));
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:557:22: error: 'TIMSK1' was not declared in this scope
returnvalue = (TIMSK1 & (1 << OCIE1A));
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:557:37: error: 'OCIE1A' was not declared in this scope
returnvalue = (TIMSK1 & (1 << OCIE1A));
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:560:22: error: 'TIMSK2' was not declared in this scope
returnvalue = (TIMSK2 & (1 << OCIE2A));
^~~~~~
/Users/mjwarne/Documents/Arduino/libraries/Tone/Tone.cpp:560:37: error: 'OCIE2A' was not declared in this scope
returnvalue = (TIMSK2 & (1 << OCIE2A));
^~~~~~
exit status 1
Compilation error: exit status 1