chipKIT® Development Platform

Inspired by Arduino™

SPI Slave Select Synchronization

Created Wed, 07 Nov 2012 18:10:32 +0000 by xray_drifter


Wed, 07 Nov 2012 18:10:32 +0000

Hello, I am wondering if anyone successfully used SPI slave select sychronization? If yes, do you think you can share a sample code on how you get it working?

I have set SSEN to 1 at slave.

When reading the received data at slave, do we need any code to poll SS pin? Thanks!


Wed, 07 Nov 2012 22:43:20 +0000

I tend to do SS on the slave manually.

I use any of the change notification pins to trigger an interrupt, in which I enable the SPI module. Then the SPI interrupt accepts the data and steps through a state machine to do put it in the right places. Then, when the SS pin goes high again the CN interrupt disables the SPI module and flags the main loop that there is an SPI packet ready for handling.


Thu, 08 Nov 2012 21:37:02 +0000

Thanks! I realized the port setting (RG9) of my slave wasn't set as input (duh...)... One reason I was trying to use SPI synch is when ever I have set SPIxBRG to less than 10, my slave starts getting overflowed (SPIROV = 1), which locks up the broad unless cleared out the buffer and clear the overflow flag... And that's why I am trying options to see I can use SPI without overflowing... So, I got the SPI slave synch select kinda working, but still not able to withstand small value of SPIxBRG...
I was also trying to use frame mode, given no sample code, I couldn't get it working neither...

Would you mind sharing part of your setting when using interrupt? Perhaps that can help me get past that hurdle... thanks!!!


Fri, 09 Nov 2012 10:22:32 +0000

All my SPI slave code is for the dsPIC, not the PIC32. The principles are the same though, but the interrupt code would be vastly different.