Datasheet
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)
Floating Point Conversion
Like the AVR Arduinos, the M0 library does not have full support for converting floating point
numbers to ASCII strings. Functions like sprintf will not convert floating point. Fortunately,
the standard AVR-LIBC library includes the dtostrf function which can handle the conversion
for you.
Unfortunately, the M0 run-time library does not have dtostrf. You may see some references
to using #include <avr/dtostrf.h> to get dtostrf in your code. And while it will compile, it does
not work.
Instead, check out this thread to find a working dtostrf function you can include in your code:
http://forum.arduino.cc/index.php?topic=368720.0
How Much RAM Available?
The ATSAMD21G18 has 32K of RAM, but you still might need to track it for some reason. You
can do so with this handy function:
Thx to http://forum.arduino.cc/index.php?topic=365830.msg2542879#msg2542879 for the
tip!
Storing data in FLASH
If you're used to AVR, you've probably used PROGMEM to let the compiler know you'd like
to put a variable or string in flash memory to save on RAM. On the ARM, its a little easier,
extern "C" char *sbrk(int i);
int FreeRam () {
char stack_dummy = 0;
return &stack_dummy - sbrk(0);
}
© Adafruit Industries https://learn.adafruit.com/adafruit-feather-m0-bluefruit-le Page 52 of 238










