I recently purchased a chinese samd21 M0 mini MC off eBay. Every thing seemed OK - did the blink test. I tried controlling a stepper but no luck even though code was simple and worked on an UNO. I tried testing the digital pins with an external LED/resistor and found to my surprise that the arduino desgnation of pin and those on the MC were out of sync as follows
Pin in Arduino Code Actual D21 pin that blinks
2 4
3 3
4 2
Hasanyone else come across this? Are any other pins switched?
The switching of pins 2 and 4 dates back to the "Arduino.org" vs "Arduino.cc" battle.
Arduino.cc SAMD21 board (Zero), and the Arduino.org boards (M0, M0 Pro) just specified the pin layout differently, probably because the design files were "shared" before some changes were made by one group or the other.
This means that you can probably get the behavior you expect by switching the board type to "m0" or to "zero (Native USB Port)", whichever one you're not using now...
AFAIK, there are no other pins that are commonly switched. But when you order from random manufacturers, you can never be 100% sure...
The Arduino.org's M0 Pro/M0 layout assigns D2 to the only SAMD21 GPIO pin that's not capable of supporting standard interrupts. It's the Non-Maskable Interrupt pin.
I can only surmise that Arduino.cc swapped the pins, as they wanted the Arduino Zero to support interrupts on D2, in order to maintain backward compatibility with the Arduino Uno. Whose only interrupt pins are on D2 and D3.