Turn M0 Pro into Zero

I have a project that uses a Zero. Now they are becoming harder to find I bought an M0 Pro and did the following to turn it into a Zero:

  1. Select Zero in IDE and burn bootloader onto the M0 Pro

  2. Wire up the ATN pin by adding this wire:

  3. Add this code to swap pins 2 and 4:

#ifdef ARDUINO_SAMD_M0_PRO
#define M0PRO_PINSWAP(pin) (((pin)==2||(pin)==4) ? (6-(pin)) : (pin))
#else
#define M0PRO_PINSWAP(pin) (pin)
#endif

Be sure to define ARDUINO_SAMD_M0_PRO somewhere! Then wrap any code using D2 or D4 with M0PRO_PINSWAP.

  1. Remove the 2 I2C pull-ups that aren't populated on the Zero.

If anyone can spot any other differences, let me know!

Hello Paul

Thanks for this, I got an M0PRO as well and I'm interested !

By the way could you explain how to use your code to invert D2 / D4 ?

Once these modifications are done, can we consider the M0PRO fully compatible with Zero sketches ?

In particular Timers Vs Pin mapping ?

Many thanks

Daniel

Hi - sure, anywhere where you call the pins in your code, wrap it with:M0PRO_PINSWAP(pin)

Then at the top add:

#define ARDUINO_SAMD_M0_PRO 1

Seeing as they're the same processor, all timer code should be identical, although I've not tested this. There may need to be additional code for pin interrupts though. Would need to test it to find out.