View previous topic :: View next topic |
Author |
Message |
x!nDy Guest
|
spi and i2c question |
Posted: Tue Feb 09, 2010 12:10 am |
|
|
Hello everybody, I have an mcu (18f26k20), temp sensor (using i2c) and a flash memory (using spi). My question is since both the i2c lines and spi lines are connected on the same pins (C5 and C4), will it create a conflict ? Do I have to turn off the temp sensor if I want to use the flash memory and vice versa for it to work properly ? Or can I use both of them even if they are both on, as long as I use the proper code ? Please help and more power to this forum. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 09, 2010 3:11 am |
|
|
The simple solution is to use software i2c on two other pins. If you can
do this, it would be much easier. The temperature sensor doesn't need
to have a high-speed interface. Software i2c at 100 KHz will work fine. |
|
|
x!nDy Guest
|
|
Posted: Tue Feb 09, 2010 4:18 am |
|
|
Thanks. But I already have a board that has all its i/o's used and the temp. sensor is already connected in (C6 and C7). So I just connect the flash memory using wires and solder it on the same pins. And sad to say I can't seem to write and read from the flash memory. I am just wondering if this is possible so that I can trim down where my possible error is located. If its in my code or in the first place its not possible to connect both i2c and spi on the same line. Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19529
|
|
Posted: Sat Aug 30, 2014 1:30 am |
|
|
DarioG's reply in the Microchip thread PCM_programmer links to there, is the one that worried me. Potentially, if the SPI device is enabled, and you happen to generate a bit pattern on the lines that matches the I2C 'start' condition, you are into unknown territory....
Now, this is a high to low transition on SDA, while SCL is high. As he says, careful choice of which wire does what, and the SPI mode, may allow you to avoid this. A stop shouldn't be a problem (the I2C chip should ignore extra stops).
It does have the 'ring' of a potential problem that might appear.
I must admit I'd tend to be looking for ways to avoid such a problem. For instance (no extra pins), using a simple logic, or even a diode-or, from the CS line to the SPI device, to ensure that the I2C device can't see such a pattern. |
|
|
|