Arduino MKRZERO as SPI Slave

Hi,
I'm trying to connect 2 MKRZero boards through SPI, one would be the master the other the slave.

I'm using sample code found here: Arduino as SPI Master and Slave Demo Code - Exhibition / Gallery - Arduino Forum.

Problem is the slave sketch, where I got the following errors on compiling:

error: 'SPCR' was not declared in this scope
error: 'SPE' was not declared in this scope
error: 'SPDR' was not declared in this scope
error: 'SPSR' was not declared in this scope
error: 'SPIF' was not declared in this scope

Arduino IDE and library installation is brand new on this machine (a couple of weeks old).

Is it possible to set MKRZero as SPI slave using the SPI.h library or do I need a different library, i.e. for an ARM chip?

Can I use SPI at all on MKRZero or is that already used by the SD Card reader?

Thanks!

Umberto

I'm using sample code found here: Arduino as SPI Master and Slave Demo Code - Exhibition / Gallery - Arduino Forum.

Problem is the slave sketch, where I got the following errors on compiling:

error: 'SPCR' was not declared in this scope
error: 'SPE' was not declared in this scope
error: 'SPDR' was not declared in this scope
error: 'SPSR' was not declared in this scope
error: 'SPIF' was not declared in this scope

That code is for a standard Arduino with a AVR MCU. Your board is ARM based, so the registers are quite a bit different.

The good news is that the SAMD21 supports SPI slave mode but you have to configure one of it's SERCOM devices to do that. It even support DMA functionality so this whole feature is quite complex to use. Unfortunately it seems that you have to do that in ultra-low-level programming (mangling registers directly) as I found no library that supports this. The datasheet is about 50 pages for this subject.

If you're not fixed to SPI a simple UART connection might be much easier to set up.

I see, thanks for the reply!