View Full Version : Need Sample Code for SCC (SPI) Slave mode

May 3rd, 2013, 03:51 PM
I have two XMC4500's on a board.. We need one to be in SPI Slave mode to communicate.

Does anyone have sample code they are willing to share? The SPI Slave app is planned, but my product needs to ship in a week..

Jun 4th, 2013, 02:45 PM
I got this all working.. Took some doing. I added some Dave like calls to set the control registers.

I have the receive side all working from interrupts and moves data at 1 mbps. I could go faster, up to about 3 mbps, with the current interrupt response code.

If anyone needs SPI Slave, I can share my code.

Jun 5th, 2013, 06:57 PM
Hi Dan,

That's was great..!!

Since our DAVE Apps has not provided SPI Slave app at the moment, perhaps you can upload your code here to share with the community here?
It would be a great help for anyone that needs to configure or use SPI in Slave mode.
Thanks in advance for your contribution. :)

Jul 29th, 2013, 09:37 AM
If your code is available, we'd love to see it. Thanks!

Oct 3rd, 2013, 08:17 AM
I'm trying to cofigure the xmc4500 usic1 ch0 as spi slave but still not working.
Could I have a look at your example code?

Many thanks

Oct 4th, 2013, 12:03 AM
Hi frankmag,

Perhaps you can refer to this post:

Example code for initialize slave is provided.

Oct 4th, 2013, 03:02 AM
Fine, now works fine.
One more question: in the xmc4500 reference manual, in the SSC configuration chapter we can see four different settings of SCLKOUT according to spi mode we have to implement.
This seems to work fine in master mode. But what about spi slave?
If I have to sniff data from a device that has a clock idle low and that updates data on clock falling edge than on the first clock edge I need to sample. This case is referred to SCLKOUT delayed by 1/2 shift clock.
In slave mode how can configure this?

Many thanks

Oct 7th, 2013, 02:10 AM
Hi Frank,

You just need to configured SCLKCFG.
For your case, should be SCLKCFG = 10B, passive level is 0 and the delay is enabled.

Oct 8th, 2013, 03:00 AM
It seems to me SCLKCFG is not working if spi is in slave mode.
From the reference manual I see that SCLKCFG sets the shift clock output configuration. This is only for spi master.
In slave mode the clock input is on SCLKIN that is DX1.
Am I missing something?