Go Down

Topic: Configure Arduino Due as SPI slave (Read 1 time) previous topic - next topic


Sep 18, 2013, 06:07 am Last Edit: Sep 18, 2013, 09:18 am by venksbond Reason: 1
In SAM3X8E datasheet section 33.8.2 pg.no:699 described how to configure SPI as slave mode. I set
Code: [Select]
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?


Nick Gammon

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?

Please post technical questions on the forum, not by personal message. Thanks!

More info:


you have to state the correct spi instance

as seen in

Code: [Select]

{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 }


Sep 20, 2013, 04:01 am Last Edit: Sep 20, 2013, 04:36 am by venksbond Reason: 1
Here i did config after digging all files from hardware folder in sam for pin register's have a try and reply.

Code: [Select]

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)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131