PDA

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



danbeadle
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..

danbeadle
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.

Jackson
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. :)

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

frankmag
Oct 3rd, 2013, 08:17 AM
Hi,
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
Frank

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

Perhaps you can refer to this post:
http://www.infineonforums.com/threads/859-SPI-(SSC)-Slave-Mode?highlight=spi+slave

Example code for initialize slave is provided.

frankmag
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
Frank

Jackson
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.

frankmag
Oct 8th, 2013, 03:00 AM
Hi,
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?

Thanks
Frank