2014-02-23 12:41 AM
Quick question: I've got a 4-pin SPI port on an STM32F3 available (and no other pins; they're all occupied) and I need to talk to an LSM9DS0 sensor. The LSM9DS0 has two separate SPI interfaces, one for the gyro part and the other for the accelerometer/compass part. Therefore I need two slave select lines, but since I've only got the four SPI pins (SCK, MOSI, MISO, SS) there's not space to have a second slave select.
Approach 1: invert the slave select pin with a transistor and connect the inverted version to the LSM9DS0's second slave select pin. This way one interface is always selected, and I can choose which one using the SS pin. However, I can't turn both off. If the LSM9DS0 is expecting to only have the slave select line pulled high when it's actually communicating, this will be a problem. Approach 2: enable 3-wire SPI mode and use the MISO pin as a second slave select. This allows for more flexibility (can turn off both interfaces) but 3-wire SPI is not exactly a standard interface and so it might cause problems. Which is the preferred option? The only real limitation is that I need it to be fast - I2C is definitely not fast enough. The transfer is half-duplex (send an address, receive a lot of data) so 3-wire SPI won't be any slower than 4-wire SPI - except that I'll need to put a resistor on the MOSI/MISO line in 3-wire mode to prevent collisions and the resistor might limit the SPI clock speed a bit.2014-02-23 05:54 AM
You have probably answered your own question. Use 3 wire mode and document it well.
Cheers, Hal2014-02-24 05:18 AM
Great, thanks for the response. I'll stick a resistor in between them just in case both chips try to drive the line at the same time.