Pin to Pad Mapping + tone()

I’d really like to like the Nano board, and use it in my current Morse Code keyer project. However, I need to save variable values after power down, and I need to generate some sound. My EEPROM issue is already posted waiting on a reply, but I’ve recently found that the board does not seem to respond well to the inclusion of the tone()/noTone() command. It seems to compile and load without error, but the sketch doesn’t run. For an example, I’ve taken the Blink sketch, and added pinMode(15, OUTPUT); & noTone(15); commands (with tone(15, 600); commanted out (BTW: Even though there are no errors, my sketches do not load reliably. I change the delay values for blink to make sure that my most current version is loaded and running.):

/* Author: Owen Lyke
 Created: April 9 2019
 License: MIT. See SparkFun Arduino Apollo3 Project for more information

 This example demonstrates usage of:
 pinMode
 delay
*/

//Various boards have status LEDs on different pins
//Most have LED_BUILTIN defined so just use that
//But if you want, you can blink any pin

//#define blinkPin 5
#define blinkPin LED_BUILTIN

void setup()
{
  pinMode(blinkPin, OUTPUT);
  pinMode(15, OUTPUT);
}

void loop()
{
  digitalWrite(blinkPin, LOW);
  delay(100);
  noTone(15);
  digitalWrite(blinkPin, HIGH);
  delay(2000);
  //tone(15, 600);
}

I’ve been building my keyer using a Mega board (memory requirements swamp Uno), but I’d like to use a smaller board in the final form. Right now, I have a working prototype using a RobotDyn MCU-PRO Mega 2560 ATmega2560-16AU, but it’s twice the size of Artemis Nano. I like that it supplies the 5v I need to run the display I’m using, but I’ll use the Artemis if that’s the only difference. Everything Artemis seems to be on hold right now. I’m using board version 1.0.6. Are there any changes on which updates can be provided?

IR,

You should check the return value of ‘tone()’ against the macro value AP3_OK. Pin 15 on the Artemis Nano maps to pad 32 of the Apollo3 microcontroller, but pad 32 is not a supported PWM pad (tone uses hardware PWM generation only for now) so I expect that ‘tone(15, x)’ on the Artemis Nano will return ‘AP3_ERR’ and not produce a tone.

l.s,

OK, thanks. As I’m just a (mostly cookbook) hacker, I appreciate your help and I’ll look at PIN function more closely in the future. Other than the schematic, does a PINOUT diagram exist for the Nano?

No worries, that’s why we’re here. Thanks for speaking up – I did not realize that the graphical datasheets had slipped through the cracks for some of our products. Actually only the Artemis module and the Blackboard Artemis have these sheets so far, but they were not linked on the product pages. Now they are under the Documents tab. So without you we’d not have caught it!

Okay so since we don’t have a graphical datasheet for the Nano you will need another simple way to know which pin numbers (labeled on the board in silkscreen) correspond to which pad numbers (on the Apollo3 microcontroller). I use the pin/pad terminology to be precise, since on different board variants the same Apollo3 pad might be labeled as different pins. This is extra clear in the case of the Blackboard Artemis where we wanted the pin functionalities to feel as familiar as possible in relation to an Arduino Uno. That means we needed to give pin 13 the SPI clock out functionality, but that functionality was only found on, say, pad 42. So then the pin to pad map is 13 → 42 for that connection.

For now the best way to get the info you need is like this:

  1. Locate the ‘variant.cpp’ file for your board. There are a couple ways to do so:

a. Browse to the files on GitHub. [Apollo3 Core/ [variants/[SparkFun_BlackBoard_Artemis_Nano/config/[variant.cpp

b Browse to the files on your computer. The path would look something like: C:\Users\you\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\1.0.6\variants\SparkFun_BlackBoard_Artemis_Nano\config\variant.cpp on Windows, or the equivalent on Mac/Linux. The GitHub method is probably easier.

  1. You should see an array called ```
    ap3_variant_pinmap

![variant_pinmap_nano.JPG|733x919](upload://sAaAHJO6rQn0TbznHmotpGmHG93.jpeg)

3. The index into the array is the * pin * number, and the number at that index is the * pad * number. So for example on the Nano ```
digitalWrite(0, HIGH)
``` would activate * pad * 13 on the Apollo3 module. (BTW, the pin numbers on the Artemis module are the pad numbers from Apollo3 - so no mapping to worry about there)

I will try to get some of our team to work on graphical datasheets for the other boards since obviously people need to know what goes where. 

P.s. here are some more links

[[Artemis Module Graphical Datasheet](https://cdn.sparkfun.com/assets/learn_tutorials/9/1/2/ArtemisModulev2.pdf)

[[All SparkFun Graphical Datasheets on GitHub](https://github.com/sparkfun/Graphical_Datasheets)

[[Artemis Graphical Datasheets on GitHub](https://github.com/sparkfun/Graphical_Datasheets/tree/master/Datasheets/Artemis)

Thanks for asking this question - I think it will help many more people.](https://github.com/sparkfun/Graphical_Datasheets/tree/master/Datasheets/Artemis)](https://github.com/sparkfun/Graphical_Datasheets)](https://cdn.sparkfun.com/assets/learn_tutorials/9/1/2/ArtemisModulev2.pdf)](https://github.com/sparkfun/Arduino_Apollo3/blob/master/variants/SparkFun_BlackBoard_Artemis_Nano/config/variant.cpp)](https://github.com/sparkfun/Arduino_Apollo3/tree/master/variants/SparkFun_BlackBoard_Artemis_Nano)](https://github.com/sparkfun/Arduino_Apollo3/tree/master/variants)](https://github.com/sparkfun/Arduino_Apollo3)