Hi all. So it turns out that this one sensor I want to use only has SPI control but all my other existing devices are I2C. My microcontroller has SPI and I2C pins on the same line basically.
The pins are multiplexed:
SDA/SDI
SCL/SDO
SCK
I read here
https://www.i2cchip.com/mix_spi_i2c.html
that if you did it properly, you could use software switch back and forth between the buses using the chip select lines to ensure the SPI ignores I2C communications.
Everything I know about I2C comes from here:
https://www.robot-electronics.co.uk/htm/using_the_i2c_bus.htm
So I2C devices ignore data that does not come in between a start/stop sequence (or after a start a sequence if you will). This somehow has to be used to ensure the I2C devices ignore the SPI communications. Normally, the I2C data does not change in the middle of a clock pulse, and when it does this means indicates an I2C start/stop sequence.
1.I haven't used SPI before, so I'm not sure how you can prevent this from happening while the SPI is doing it's stuff (so a false I2C trigger doesn't happen).
2. Do the I2C pull-up resistors do anything to affect the SPI?
3. I2C filters have filters while SPI does not, but this device is a compass and has to sit a foot away form everything else (noisy motors and stuff). I've never had to filter a digital signal before...just analog where I knew exactly what bandwidth I wanted and only cared about uniform phase response (rather than uniform magnitude response). Does anyone know what kind of filters to start looking at (and something about clock harmonics too? The only thing applicable thing I remember is elliptical filter- the word, nothing else).
4. Also about shielding (separate from the rest). My robot has an aluminum base and a roll cage which most of the electronics sit between. But some periphreals sit on top of the roll cage so I have a bunch of I2C/SPI and "motor-level current" cables running up and down the one foot distance between the base and roll cage. There are also noisy motors sitting underneath the baseplate. My motors are inside some aluminum motor mounts that are essentially an 5-sided aluminum box mounted onto a relatively large aluminum plate. The open face of the motor mounts enclosure faces the ground. THe electronics sit on top of the aluminum base. I'm wondering how this compares to a Faraday cage in terms of shielding since it's not totally enclosed, but rather is a metal plate and a 5-sided "cage" sitting between the detector/receiver (with the open face pointing away from the receiver). I'm worried about the noise mucking up things. I think the biggest problem right now is the power cables running up and down.
==============
EDIT: I just noticed that the compass's SPI interface is half duplex. I guess this means only the SDI/SDA or SDO/SCL line is transferring SPI data at any one time. So if I just hold the unused line low, it should never interfere with the I2C? If so...that makes things so much simpler. I guess that answers question 1.
The pins are multiplexed:
SDA/SDI
SCL/SDO
SCK
I read here
https://www.i2cchip.com/mix_spi_i2c.html
that if you did it properly, you could use software switch back and forth between the buses using the chip select lines to ensure the SPI ignores I2C communications.
Everything I know about I2C comes from here:
https://www.robot-electronics.co.uk/htm/using_the_i2c_bus.htm
So I2C devices ignore data that does not come in between a start/stop sequence (or after a start a sequence if you will). This somehow has to be used to ensure the I2C devices ignore the SPI communications. Normally, the I2C data does not change in the middle of a clock pulse, and when it does this means indicates an I2C start/stop sequence.
1.I haven't used SPI before, so I'm not sure how you can prevent this from happening while the SPI is doing it's stuff (so a false I2C trigger doesn't happen).
2. Do the I2C pull-up resistors do anything to affect the SPI?
3. I2C filters have filters while SPI does not, but this device is a compass and has to sit a foot away form everything else (noisy motors and stuff). I've never had to filter a digital signal before...just analog where I knew exactly what bandwidth I wanted and only cared about uniform phase response (rather than uniform magnitude response). Does anyone know what kind of filters to start looking at (and something about clock harmonics too? The only thing applicable thing I remember is elliptical filter- the word, nothing else).
4. Also about shielding (separate from the rest). My robot has an aluminum base and a roll cage which most of the electronics sit between. But some periphreals sit on top of the roll cage so I have a bunch of I2C/SPI and "motor-level current" cables running up and down the one foot distance between the base and roll cage. There are also noisy motors sitting underneath the baseplate. My motors are inside some aluminum motor mounts that are essentially an 5-sided aluminum box mounted onto a relatively large aluminum plate. The open face of the motor mounts enclosure faces the ground. THe electronics sit on top of the aluminum base. I'm wondering how this compares to a Faraday cage in terms of shielding since it's not totally enclosed, but rather is a metal plate and a 5-sided "cage" sitting between the detector/receiver (with the open face pointing away from the receiver). I'm worried about the noise mucking up things. I think the biggest problem right now is the power cables running up and down.
==============
EDIT: I just noticed that the compass's SPI interface is half duplex. I guess this means only the SDI/SDA or SDO/SCL line is transferring SPI data at any one time. So if I just hold the unused line low, it should never interfere with the I2C? If so...that makes things so much simpler. I guess that answers question 1.
Last edited: