Go Down

Topic: Turn M0 Pro into Zero (Read 476 times) previous topic - next topic

paulsoulsby

Feb 09, 2018, 06:39 pm Last Edit: Feb 10, 2018, 11:38 am by paulsoulsby
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:
Code: [Select]
#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.

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


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

DR49

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

paulsoulsby

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

Then at the top add:
Code: [Select]
#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.

Go Up