Datasheet

analogWrite() PWM range
On AVR, if you set a pin's PWM with analogWrite(pin, 255) it will turn the pin fully HIGH. On the ARM cortex, it will set it
to be 255/256 so there will be very slim but still-existing pulses-to-0V. If you need the pin to be fully on, add test
code that checks if you are trying to analogWrite(pin, 255) and, instead, does a digitalWrite(pin, HIGH)
Missing header files
there might be code that uses libraries that are not supported by the M0 core. For example if you have a line with
#include <util/delay.h>
you'll get an error that says
fatal error: util/delay.h: No such file or directory
#include <util/delay.h>
^
compilation terminated.
Error compiling.
In which case you can simply locate where the line is (the error will give you the file name and line number) and
'wrap it' with #ifdef's so it looks like:
#if !defined(ARDUINO_ARCH_SAM) && !defined(ARDUINO_ARCH_SAMD) && !defined(ESP8266) && !defined(ARDUINO_ARCH_STM32F2)
#include <util/delay.h>
#endif
The above will also make sure that header file isn't included for other architectures
If the #include is in the arduino sketch itself, you can try just removing the line.
Bootloader Launching
For most other AVRs, clicking reset while plugged into USB will launch the bootloader manually, the bootloader will
time out after a few seconds. For the M0, you'll need to double click the button. You will see a pulsing red LED to let
you know you're in bootloader mode. Once in that mode, it wont time out! Click reset again if you want to go back to
launching code
Aligned Memory Access
This is a little less likely to happen to you but it happened to me! If you're used to 8-bit platforms, you can do this
nice thing where you can typecast variables around. e.g.
uint8_t mybuffer[4];
float f = (float)mybuffer;
You can't be guaranteed that this will work on a 32-bit platform because mybuffer might not be aligned to a 2 or 4-
byte boundary. The ARM Cortex-M0 can only directly access data on 16-bit boundaries (every 2 or 4 bytes). Trying
to access an odd-boundary byte (on a 1 or 3 byte location) will cause a Hard Fault and stop the MCU. Thankfully,
there's an easy work around ... just use memcpy!
uint8_t mybuffer[4];
float f;
memcpy(f, mybuffer, 4)
© Adafruit Industries https://learn.adafruit.com/adafruit-feather-m0-adalogger Page 44 of 47