Multiple SPI devices

07 Nov 2010 . Edited: 07 Nov 2010

I have an SCP1000 connected to the SPI bus at p5,p6 and p7 with CS at p8 and it works fine.

Then I connected up an SD card holder using the same SPI bus but with p26 as the CS for the card.

This pretty much kills the SCP 1000 ( even with no card inserted ) just setting up the bus seems to get things confused.

I have tweaked the SDcard library so that it runs at the same frequency as the SCP1000 to no avail.

07 Nov 2010

You didn't say if connecting an SDcard worked but I suppose that's kind of immaterial. I looked up the data sheet for the SCP1000 and it didn't say whether it's MISO pin goes tri-state when it's CSB is not asserted. If it does not then it cannot share an SPI bus. I have an SDcard holder and two FLASH devices on one SPI bus and they all work fine together with or without a card inserted.

What sort of SDcard holder are you using?

07 Nov 2010

The SCP appears to tristate the bus when cs is not asserted. Applying a 100k pull up resistor clearly changes the bus state outside the cs window if I 'scope it.

The sd card holder is an arbitrary part from Farnell and I can read and write to the card succesfully. At first I thought the sd card was the one holding the bus but taking the card out of the connector made no difference. In fact the scp was holding the Miso bus firmly low during the cs period. The only way to get things working again was to disable all the code instantiating the SD card object and completely depowering the mBed to get the scp to come back to life.

There appears to be some mismatch between the two libraries in use. ( SCP1000 and SDCard )

 

I take it that firing up the SCP and the SD card on the first SPI bus like this ....

// Instantiate the interface stuff
SerialBuffered sms(p28, p27);       // Serial port to SMS modem
SCP1000 apress(p5,p6,p7,p8);        // SCP1000 connected to first SPI port.             
SDCard sd(p5,p6,p7,p26, "SDCard");  // SPI bus and pin 26 as select.                    
I2C i2cbus(p9, p10);                // I2C IO expander
SHT75 sht(p12, p11);                // SHT bit banged port  ( clock and data )          to device

Is the way it should be done?

08 Jul 2011

Were you able to solve this problem? I'm thinking of sharing the SD SPI with other device. Perhaps I'll have to declare a generic SPI bus and change the SD library so I can manually pass the bus to each device's library.