Pages: [1]   Go Down
Author Topic: Configure Arduino Due as SPI slave  (Read 664 times)
0 Members and 1 Guest are viewing this topic.
Singapore
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In SAM3X8E datasheet section 33.8.2 pg.no:699 described how to configure SPI as slave mode. I set
Code:
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
« Last Edit: September 18, 2013, 02:18:15 am by venksbond » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

/Applications/Arduino_Due_1.5.2.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/sam3n/include/component/component_spi.h

Also here, and in a few other places:

/Applications/Arduino_Due_1.5.2.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/sam3xa/include/component/component_spi.h

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?

Logged

Ottawa,Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

you have to state the correct spi instance

as seen in
/hardware/arduino/sam/system/libsam/source/spi.c

Code:
{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 }
Logged

Singapore
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
void setup();
{
pinMode(PIN_SPI_MISO,OUTPUT);
  REG_SPI0_MR = REG_SPI0_MR & 0xFF0F00B6;
  REG_SPI0_WPMR = REG_SPI0_WPMR & 0xFF0F00FE;
  
  REG_SPI0_CR=0x1;
  
  REG_SPI0_CSR=0x00000400; //Configured to 8bit transfer & 21MHz
}

Im getting "FF" reply from due(slave) in rpi(master)
« Last Edit: September 19, 2013, 09:36:19 pm by venksbond » Logged

Pages: [1]   Go Up
Jump to: