Question
SPI to the LSM9DS0 using only four pins
Posted on February 23, 2014 at 09:41
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.