Swapping MISO and MOSI pins on arduino Zero

So I Goofed :frowning:

I have made a PCB with a SAMD21D chip running the Arduino bootloader, however, in my infinite wisdom, I managed to get MISO and MOSI around the wrong way.

Is there any way to change this with software making use of the SERCOM MUX, or am I cutting traces?

Thanks in advance for the help,
Skipper

Hi Skipper,

Don't get out the scalpel just yet.

Fortunately, if you've based your custom design on the Arduino Zero, the way MISO and MOSI are arranged it's possible to swap them in software.

The easiest way is to go to the Arduino Zero's "variant.h" file. This is located in the directory (on my Windows machine at least) at:

C:\Users\Computer\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.18\variants\arduino_zero\

In the variant.h file just change the SPI interface pin definitions to this:

/*
 * SPI Interfaces
 */
#define SPI_INTERFACES_COUNT 1

#define PIN_SPI_MISO         (23u)
#define PIN_SPI_MOSI         (22u)
#define PIN_SPI_SCK          (24u)
#define PERIPH_SPI           sercom4
#define PAD_SPI_TX           SPI_PAD_0_SCK_3
#define PAD_SPI_RX           SERCOM_RX_PAD_2

This should then allow you to use the Arduino SPI library as normal.

Just bear in mind that you'll need to make this change each time you update the Arduino Zero core files to the latest version. We're currently at Version 1.6.18.

Thanks, MartinL,

This worked perfectly