Using tone() with Artemis Nano

I am experimenting with basic audio synthesis and trying to use tone() with an Artemis Nano on pin 14 or 16 (no other outputs or inputs). The following code produces a tone as expected:

digitalWrite(soundOut, HIGH);
delay(3);
digitalWrite(soundOut, LOW);
delay(3);

However, “tone(16, 200);” and “tone(16, 110, 10);” do not work on the same pins. Is the tone() function https://www.arduino.cc/reference/en/lan … d-io/tone/ not supported on the Artemis platform?

If so, are there other unsupported functions and where would I find a list of them? While I have experience from long ago with other programming platforms and with PIC, this is my first project in a while and my first go with Arduino. I’m starting to wonder if Artemis was a bad place to start as a beginner…

Advice appreciated!

best,

Matthew

Hello, which pin of the Artemis nano have you declared as the pin in the function below?

tone(pin, frequency, duration)

As far as I know, it has to be a PWM pin.

The Artemis Nano supports PWM on 17 pins. If you are using the library V2.x, make sure to use A14 OR A16 ( not just 14 or 16 ).

Thanks.

I’m using v2.2.1. I’ve tried both A14 and A16 to no avail.

This code works

int soundOut = 16;

void setup() {
  pinMode(soundOut, OUTPUT);
}

void loop() {
    digitalWrite(soundOut, HIGH);
    delay(3);
    digitalWrite(soundOut, LOW);
    delay(3);
  }

This code does not:

int soundOut = 16;
void setup() {
  pinMode(soundOut, OUTPUT);
}

void loop() {
    tone(soundOut, 200);
  }

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

Do not include an extra / external library, tone() is already included in the Artemis analog-files.

The issue is related to an error in the Artemis V2 library.

Locate the Artemis boards Library location. Mine (on Ubuntu) is on /.arduino15/packages

On Windows I would expect \AppData\Local\Arduino15\packages\

Then go to the directory: SparkFun/hardware/apollo3/2.1.1/cores/arduino/sdk/core-implement.

There is a file CommonAnalog.cpp , on line 184 you will find

   if(duration){
        uint32_t stop_time = millis() + duration;
        while(millis() < stop_time){};
    }

   ap3_pwm_output(pad, 0, 0, clk);

It will undo /stop tone immediately without a duration (same as notone()). Move the ap3_pwm_output line with the if statement like :

    if(duration){
        uint32_t stop_time = millis() + duration;
        while(millis() < stop_time){};
        ap3_pwm_output(pad, 0, 0, clk);
    }

Save the change and recompile. it will now work.

I have created an issue on github so it can be corrected in future versions (https://github.com/sparkfun/Arduino_Apollo3/issues/471)

That did it! Thanks a ton, @paulhva!

Last n00by question if you’re able: Where should I have seen to use A16 instead of 16?

best,

Matthew

Good to hear it works.

There are different definitions for pins which are often mixed. There are PinNames, PinNumbers, PadNumbers etc.

PinNames (like A16 or D1) are the names as printed on the board and/or as you find them by looking at pin-out documents of a board. The PinName is a variable that is defined in the board library. You should always use these in the sketch to make your sketch easier to compile across different platforms.

Each pin is connected to the processor. This connection point on a processor is called pad. The pinName does not need to be connected to the same padNumber. Take the Artemis Nano Pin A16. Looking at the schematics you will see it is connected to PadNumber 12. Thus variable A16 = D16 is defined as 12 in the V2 library for a Nano. This PinName to PadNumber connection can be different for each Artemis variant. If you take an Artemis ATP for example the pinNames on the board ARE the same the padNumbers.

On the Nano, if you provide A16 in the call: tone(A16, 200, 500); the boards library receives tone(12, 200, 500); This is then translated by the V2 library and making the PWM connection to the correct pad (12). If you provide 16 the boards library receives tone(16, 200, 500); it will output to padNumber 16 (which is NOT connected to a pin on the Nano)

If you are not confused yet, you will be now : Instead of PinNames, documentation is often referrring to PinNumbers. To make it worse in many boards libraries they also use variable name PinNumbers where they actually mean padNumbers.

That’s a huge help, @paulvha. Thanks for taking the time. I think I understand well enough to know what to look out for. Best, M