Datasheet
Adapting Sketches to M0
The ATSAMD21 is a very nice little chip but its fairly new as Arduino-compatible cores go.
Most sketches & libraries will work but here's a few things we noticed!
The below note are for all M0 boards, but not all may apply (e.g. Trinket and Gemma M0 do
not have ARef so you can skip the Analog References note!)
Analog References
If you'd like to use the ARef pin for a non-3.3V analog reference, the code to use is
analogReference(AR_EXTERNAL) (it's AR_EXTERNAL not EXTERNAL)
Pin Outputs & Pullups
The old-style way of turning on a pin as an input with a pullup is to use
pinMode(pin, INPUT)
digitalWrite(pin, HIGH)
This is because the pullup-selection register is the same as the output-selection register.
For the M0, you can't do this anymore! Instead, use
pinMode(pin, INPUT_PULLUP)
which has the benefit of being backwards compatible with AVR.
Serial vs SerialUSB
99.9% of your existing Arduino sketches use Serial.print to debug and give output. For the
Official Arduino SAMD/M0 core, this goes to the Serial5 port, which isn't exposed on the
Feather. The USB port for the Official Arduino M0 core, is called SerialUSB instead.
In the Adafruit M0 Core, we fixed it so that Serial goes to USB when you use a Feather M0
so it will automatically work just fine.
However, on the off chance you are using the official Arduino SAMD core not the Adafruit
version (which really, we recommend you use our version because as you can see it can
vary) & you want your Serial prints and reads to use the USB port, use SerialUSB instead of
Serial in your sketch
© Adafruit Industries https://learn.adafruit.com/adafruit-feather-m0-bluefruit-le Page 48 of 238










