SparkFun Forums 

Where electronics enthusiasts find answers.

Topics pertaining to the Arduino Core & software used with the Artemis module and Artemis development boards.
#208114
On the schematic (https://cdn.sparkfun.com/assets/5/5/1/6 ... s-Nano.pdf), there are multiple ports listed as SCL and SDA ports. There are a pair in the Qwiic port (I'm not interested in that), there are a pair that I think must on ports 11 and 13, and so on. Which ports am I supposed to use? Can I control which of these ports the board uses for SCL/SDA? Thanks.
#216046
I am equally confused about the i2c on the Artemis Nano. I have a sketch running successfully on the Artemis RedBoard communicating with a Lidar-Lite v3HP via an i2c connection to the labeled SDA/SCL pins. But, when I tried to move this over to the Nano the only labeled i2c to be exposed to pins are SDA3/SCL3. Your documentation indicates that 17/18 can be used as SDA2/SCL2 but, apparently that would be through the Qwiic connector which I would prefer not to use and anyhow I need whatever is equivalent to the SDA/SCL of theArtemis RedBoard (connected, I believe, to Apollo3 PAD 5/6). I tried the TwoWire myWire(n); solution forn of 0 through 5 with no success (just received nacks). I noted a comment somewhere that not all third party libraries are set up to recognize port redirects. So:
How do you access a connection to the Apollo3 PAD 5/6 on the Nano?
What would one have to add to a third party library to make it accept port redirects?
Since you show the Lidar-Lite v3HP Arduino library on the product page, do you have a fork for this library specifically?
User avatar
By liquid.soulder
#216097
Artemis can have up to 6 I2C ports
https://github.com/sparkfun/Arduino_Apo ... #L363-L389

If variants have dedicated pins for I2C they are defined as Wire, Wire1, ... , Wire5
https://github.com/sparkfun/Arduino_Apo ... .h#L37-L41

If your variant does not have the desired Wire port defined then you should be able to use the TwoWire(n) method that you mentioned. There are no pin multiplexing options for I2C ports so see Table 559: from the Apollo3 Blue Datasheet (pg. 381) to figure out which apollo3 pads that I2C module corresponds to. Then use the pin mapping to see what Arduino pin numbers those correspond to for your variant:

https://github.com/sparkfun/Arduino_Apo ... pp#L25-L52
#216236
Thanks for responding but that's not completely helpful. For example, the RedBoard Artemis has an A4 label and a 5 label, neither of which appear on the variant list. There are SDA and SCL labels - are they SDA0 and SCL0 if so, then is MISO = MISO0 and MOSI= MOSI0 which map to the same pads as SDA0 and SCL0??
It would bevery helpful if you could please just provide a clear, unambiguous mapping from all your RedBoard Artemis boards to the respective Apollo 3 pads. Also for us long time Arduino board users, which of their silkscreen labels would be equivalent to the basic SDA, SCL, MOSI, MISO, SCK, TX, and RX to which we're accustomed.
I'm trying hard to replace the Atmel with Apollo but you're not making it as easy and intuitive as I've come to expect of SparkFun.
User avatar
By liquid.soulder
#216253
Here is the pin map for the RedBoard Artemis:
https://github.com/sparkfun/Arduino_Apo ... pp#L25-L60

The line defining the "A4" pin is number 48 - it tells you that pin "A4" can also be called "20" and that those pins are handled by the Apollo3 pad #16.
This is confirmed by the following two lines:
https://github.com/sparkfun/Arduino_Apo ... nt.cpp#L72
https://github.com/sparkfun/Arduino_Apo ... iant.h#L68

So when you use "A4" in functions like "digitalWrite" it equates to the number 20. The number 20 is the index into the pin map array, and at that index the pad # listed is 16. So then internally operations are applied to pad # 16 of the Artemis module.

Here's the pin map entry for pin 5: https://github.com/sparkfun/Arduino_Apo ... nt.cpp#L33



One of my qualms with the RBA is that certain pins do not have a pin number listed in silkscreen. It makes it hard to use them for functions other than what is listed (such as I2C or SPI).
There's no better way to solve that than be either referencing the datasheet or this portion of the variant.h file: https://github.com/sparkfun/Arduino_Apo ... .h#L91-L98


On most boards you should begin using Wire and SPI before moving on to WireN and SPIN. These peripherals are also mapped so that they will appear on the "expected" marked pins (unless no pins are marked for SDA/SCL or MISO/MOSI/SCLK, cause then there is no expectation and they are just on the pins they are on)


Let's go over how that works:
We define a value for "AP3_Wire_IOM" with this line: https://github.com/sparkfun/Arduino_Apo ... iant.h#L41
In this case the value is 4

In the Wire library for Apollo3 that #define constant is used to create the standard "Wire" object that everyone knows and loves, and underneath it uses IO Main (IOM) #4.
https://github.com/sparkfun/Arduino_Apo ... #L363-L369

By checking the datasheet we see that IOM4 SCL is on Apollo3 pad 39 and IOM4 SDA is on Apollo3 pad 40.
https://cdn.sparkfun.com/assets/learn_t ... v0_9_1.pdf

By returning to the pinmap we can see that those pad #s correspond to pins 14 and 15, which are also labeled SDA4 and SCL4.
https://github.com/sparkfun/Arduino_Apo ... pp#L42-L43

Pins 14 and 15 are located on the board in the same place as the Arduino Uno I2C pins for shield compatibility, but unlike the Uno they are not connected to A4 and A5. They are their own independent pins (possible because Apollo3 has far more pads available than the 328p)

So - SCL and SDA on the RBA correspond with "Wire" in software and "IOM4" within the Apollo3. The internal details are unimportant and abstracted away for most users.

In the case of the SPI pins (MOSI, MISO, SCLK) they are accessed with the "SPI" object in software but they use "IOM0" behind the scenes.


I'm unsure how I can better help you. The unambiguous mappings are all available here:
https://github.com/sparkfun/Arduino_Apo ... f/variants

On top of that the RedBoard Artemis almost 100% pin-compatible with the Arduino Uno - sketches written for one should work on the other without modification. (performance concerns aside)

We had hoped that would be intuitive enough. Is there a way we can make it easier? I'd be happy to consider some changes. Thanks!
User avatar
By liquid.soulder
#216305
Yeah you bet - that's in the last link from the first post. It is best to use the latest resources from GitHub because if we end up fixing a mistake it will appear there. Maintaining other copies across the web would turn into a nightmare. You can also just use the pin numbers that are silkscreened right on the PCB - they will work directly in Arduino thanks to the internal pin mappings. P.s. you can find all the mappings for all of our boards by starting at this link:
https://github.com/sparkfun/Arduino_Apo ... r/variants

then clicking on the board you are interested in (e.g. redboard_artemis_nano) then opening the file "config/variant.cpp"
#216375
Thanks for the detailed explanation. I think that I understand now but just want to confirm which pins on the RedBoard Artemis Nano are the standard SDA/SCL recognized by Wire. By extension of your explanation for the RedBoard Artemis would they be 9/TX1, 10/RX1 which map to Apollo3 pads 39 and 40? If so why aren't they silkscreened SDA/SCL?
User avatar
By liquid.soulder
#216381
Not quite. If you are trying to find the default Wire pins for any board you can follow this process:

1. Check the "variant.h" file for the definition of "AP3_Wire_IOM"
2. Refer to the Apollo3 datasheet to see which pads that IOM uses for SDA / SCL
3. See if those pads are listed in the variants pin map in "variant.cpp" (if they are not then it is possible that they are not directly accessible by the user, for example hidden within the Qwiic connector)

Applying these steps to the RBA Nano:
1. "variant.h" lists "AP3_Wire_IOM" as "2"
https://github.com/sparkfun/Arduino_Apo ... /variant.h

2. Apollo3 Blue datasheet shows that IOM2 uses pads 25 and 27 for "M2SDAWIR3" and "M2SCL" respectively
https://cdn.sparkfun.com/assets/learn_t ... v0_9_1.pdf

3. The "variant.cpp" pin map does list 25 and 27 (they are Arduino pins 17 and 18). That means you can control them with standard Arduin functions like digitalWrite() and pinMode(). However looking on the silkscreen of the board there are no pins labeled 17 or 18. What gives? Well these pins are within the Qwiic connector. This makes it really easy to use other Qwiic products on the Wire bus.
https://github.com/sparkfun/Arduino_Apo ... ariant.cpp

Footnote: what if you don't want to use the Qwiic connector?
1. Find exposed pins on your board that are I2C capable that use just one IOM instance.
on RBA Nano you have these options:
- pins 7 and 6 using IOM3
- pins 9 and 10 using IOM4
- pins 11 and 13 using IOM0

2. Use the IOM number (#) to construct your own Two_Wire object - it is forced to use the associated pins b/c there is no pin muxing on Apollo3 IOMs
```
Two_Wire myWire(#);
```

3. Use that Two_Wire object just like you would have used "Wire"
```
myWire.begin()
myWire.read()
etc...
```
#216383
Thanks again for patiently answering my question in great detail - I really appreciate it. That will be very helpful as I try to get more familiar with the Artemis products. I would offer a few suggestions which might be helpful to others like me trying to transition from Arduino boards. First, some kind of introduction to the general concept of mapping from IOM to Pads to slkscreen would be helpful as well as where to find the different files that you have referred me to, above. Second, all that you have had to explain to me is kind of like someone asking the time but getting a lesson on how to build a watch. You have set the expectation that your Arduino core makes it "plug and play" but not all third party libraries support Two Wire port reassignments so you should, at least, let the casual Arduino user know that and , for example, that they need to use the qwiic connector to get to the accustomed SDA/SCL on the Nano as you just explained to me. Finally, I found the documentation a little lacking as regards Vin - I had to dig into the schematic to learn the specifics. I hope that helps. Thanks again!
#219931
For informational purposes - there are two pogo-pin pads on the underside of the board which can be used to solder into the I2C bus without going through qwic. The SDA pad is just inboard of A16. The SCL jumper is the one further along the long header toward the Artemis module. Of the group of three jumpers next to the JTAG it's the one closest to the SDA jumper.

They're pretty small but I managed to get a 30AWG soldered to them without too much trouble. Be sure to put a fine tip on before you heat the ol' iron up.
#234952
For the Nano, you can reference the "D0-16" pins from "PinNames.h", the defined name "AM_BSP_GPIO_IOM2_SCL" in "am_bsp_pins.h", or the Artemis pin numbers in "am_bsp_pins.h", e.g. "27"
This is very confusing due to the fact that in the Artemis documentation and schematic the Artemis shows pins as "D6" and the board pin is "11."
In "PinNames.h" the board pins are reference as "D0-D16" mapped back to the Artemis Pins. It would make things easier to clean up the schematic or add a B, such as BD (Board Digital), or AD (Artemis Digital)
Schematic:
https://cdn.sparkfun.com/assets/5/5/1/6 ... s-Nano.pdf
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum