Maple-Arduino Compatability Notes
The biggest difference between the Maple and most Arduino boards is that the
Maple uses a 32-bit ARM Cortex-M3 architecture chip while the Arduinos have
8-bit Atmel AVR chips. The different instruction set means that machine code
(executable binary programs) is incompatible between the two and a different
compiler (actually just a different version of gcc) is required. The compiler
for the regular Arduino IDE is the popular "avr-gcc" package; the compiler
for the Maple version of the IDE is Codesourcery's edition of gcc for the
ARM EABI target (aka "arm-non-eabi-gcc").
The bitwidth of the processor means that the Maple can process 32-bit operations
in a single instruction (for instance add two 32-bit integers together) while
an Arduino processor would have to split up large operations into several
smaller ones. In a lot of cases 8-bit operations are plenty (integers 0-255,
single characters of text, etc), but if you're dealing with higher resolution
data the speed up could be significant. A trade-off is that code could be
larger as well; program instructions and memory locations can be up to 32-bits
each as well, which in the worst case would quadruple program size. In reality
the removal of extra instructions and fancy packing together of simple
instructions means that programs aren't much larger (or are even smaller).
The numbering of headers is different; on the Maple each GPIO has a unique
number: D0, D1, D2, all the way up to D37 (actually there are a couple
more...). On the Arduino the analog pins are numbered seperately (A0-A5) from
the digital pins (D0-D13).
The incompatible hardware differences are:
- i2c port: on most Arduinos the i2c port is
Analog Input 4 (SDA) and Analog Input 5 (SCL); on the Maple i2c port 1 is D5
(SCL) and D9 (SDA), and i2c port 2 is D29 (SCL) and D30 (SDA). It should be
possible to skywire, sacraficing signal quality (increased capacitance). Or
i2c can be bit banged reasonably well in software. Or this peripheral could
potentially be rerouted internally (but we haven't looked in to it).
- PWM on D10: all the other standard Arduino PWM
headers have PWM functionality on the Maple (D2,D3,D6,D9,D11), but not D10.
We did our best! It may be possible to reroute this peripheral internally
using low level configuration (but we haven't looked in to it).
- No External Voltage Reference: The Arduino has
an Aref pin which allows the use of an external ADC voltage reference; the
Maple has an extra GPIO pin (14) with PWM capability in this spot, and does
not allow an external voltage reference to be configured.
- EEPROM: the Maple does not have any internal
EEPROM. This functionality can be emulated with regular peristant flash
memory, or with an external EEPROM chip.
- ISP Programming: the Maple does not use an
ISP/ICSP bus for debugging; it uses JTAG.
- 32-bit int: many standard functions either expect or return full
32-bit (4 byte) integer values instead of the regular 16-bit (2 byte)Arduino
values.
- pinMode types: any GPIO (including analog pins) can be configured
into one of the following modes with a single call to pinMode: OUTPUT,
OUTPUT_OPEN_DRAIN, INPUT_FLOATING, INPUT_PULLUP, INPUT_PULLDOWN. Additionally
the PWM and Analog Input pins can be configured as INPUT_ANALOG and PWM
respectively. See GPIO docs for more info.
- Serial1 syntax: like the Arduino Mega, the Maple has multiple
USART ports. By default
Serial
is not maped to any of them,
use Serial1
through Serial3
instead.
tone()
unimplemented: On the TODO list!
pulseIn()
unimplemented: On the TODO list!
- 16-bit PWM
- 12-bit ADC
Shield/Device
| Compatable?
| Notes
|
Ethernet Shield
| Yes!
| Tested; no library yet
|
Midi Shield
| Yes!
| Tested?
|
XBee Shield
| Unknown
|
|
Bluetooth Shield
| Unknown
|
|
WiFi Shield
| Unknown
|
|
Cellular Shield Shield
| Unknown
|
|
Library
| Ported?
| Notes
|
Wiring
| Not yet
| In progress
|
Ethernet
| Not yet
| Planned
|
EEPROM
| No
| The Maple doesn't have EEPROM; use flash instead. This library could be
emulated?
|
Ethernet
| Not yet
| Planned
|
Firmata
| Not yet
| Planned
|
Matrix
| Not yet
|
|
SoftwareSerial
| Not yet
| Planned
|
Sprite
| Not yet
|
|
LiquidCrystal
| Not yet
| Planned
|
Stepper
| Not yet
| Planned
|
- First check the hardware and header differences above and see if your
project or shield needs to be modified (eg, add 3.3v level converters or
reroute PWM to header D10).
- Check for ported library functionality. We intend to port all of the
core and popular libraries (like Wire, Ethernet, and the LCD screen driver),
but we may not be finished.
- Check for peripheral conflicts; changing the configuration of timers
and bus speeds for a feature on one header may impact all the features on
that hardware "port"; for example changing the timer prescaler to do long
PWM pulses could impact i2c communications on nearby headers.
- Rewrite any low-level code. This could potentially be very difficult, but
hopefully you've used the Arduino libraries to abstract away the registers
and other hardware-specific details. Your sketch probably doesn't have any
low-level code; a library which wraps a particular peripheral very well may.
- Redeclare variable sizes if necessary: generics like
int
will probably work unless you depend on side-effects like rollover.
- Check every pinMode: the Maple has more modes for GPIO pins. For example,
make sure to set analog pins to
INPUT_ANALOG
before reading and
PWM pins to PWM
before writing.
- Modify PWM writes: pinMode must be set to
PWM
, the frequency
of the PWM pulse configured, and the duty cycle written with up to 16-bit
resolution.
- Modify ADC reads: analogRead takes the full pin number (not 0-5) and
returns a full 12-bit reading. The ADC pin must be set to
INPUT_ANALOG
using pinMode first.
- Possibly convert all Serial-over-USB communications to use HardwareUsb
instead of HardwareSerial. The Maple has a dedicated USB port which is not
connected to the USART TX/RX pins in any way.
- Check timing; Maple clock cycles are just 13.9 nanoseconds, though the
peripheral bus speeds (which limit GPIO output) are clocked slower.
About this Document
A more recent version of this document may be available from the
LeafLabs website. Our documentation is
versioned on
github; you can track changes
to the master branch at
this link.
This documentation is released under a
Creative Commons Attribution-Share Alike 3.0 license.
Translations are welcomed; give us a ping to make sure we aren't in the
process of revising or editing first.