Configure Arduino Due as SPI slave

In SAM3X8E datasheet section 33.8.2 described how to configure SPI as slave mode. I set SPI_MR = SPI_MR & 0xFF0F00FE; MSTR set to 0. when i compiled got

error: 'SPI_MR' was not declared in this scope. Is it right?

Thanks Venkatesh

I get the same error, however it seems to be declared here on my Mac:


Also here, and in a few other places:


I don’t know enough about the build process to comment on why those includes don’t seem to be active, perhaps someone else can help?

you have to state the correct spi instance

as seen in

{snip out lots of code}
extern void SPI_Configure( Spi* spi, uint32_t dwId, uint32_t dwConfiguration )
    pmc_enable_periph_clk( dwId ) ;
    spi->SPI_CR = SPI_CR_SPIDIS ;

    /* Execute a software reset of the SPI twice */
    spi->SPI_CR = SPI_CR_SWRST ;
    spi->SPI_CR = SPI_CR_SWRST ;
    spi->SPI_MR = dwConfiguration ;   ///<------------------------------------------------------------
{more code follows }

Here i did config after digging all files from hardware folder in sam for pin register's have a try and reply.

void setup();
  REG_SPI0_MR = REG_SPI0_MR & 0xFF0F00B6;
  REG_SPI0_CSR=0x00000400; //Configured to 8bit transfer & 21MHz

Im getting "FF" reply from due(slave) in rpi(master)