SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By vane_caracas
#20319
Hi, i'm doing a project with a i2c memory, a trw-2.4g rf and a pic 18f4620...

The comunication between the rf and the pic is by spi serial comunication (MSSP of the MCU) And the memory use i2c comunication...

I still haven't done the union of the rf and memory on the pic, only separately...and i have the next doubt.....may be a problem work with the two diferents serial comunicacion??? its important to tell that when i use the memory i didnt use the rf... it means, that i didnt use them at the same time.

What do you know about it???

Thanks for your help... :)
By brennen
#20326
I wouldn't recommend running I2C and SPI on the same bus. This isn't really a problem for the SPI peripherals as their outputs are expected to be in high-impedance unless you assert their chip-select (which you wouldn't do while reading from an I2C peripheral). However, since I2C does not have any chip select or chip enable lines (at least as far as the protocol is concerned), then it is possible that you could send out a command over the bus to an SPI peripheral that the I2C memory might interpret as a command for itself. This could cause bus contention and other bad things if both the SPI device and the I2C device try to talk at the same time.

However, if your I2C memory does have some sort of enable line that will basically turn off the communications port, then I can't think of any reason that there would be a major problem doing this. You'll probably have to be careful of keeping track of your bitrates when you're talking to the different devices as SPI is considerably faster than I2C in most cases. The pull-up resistors that I2C requires shouldn't interfere with SPI as it is push-pull anyway.

Somebody else may disagree with me that has more experience mixing protocols, as I've never actually done this myself.
By vane_caracas
#20525
Hi, brennen....I have to work with i2c procotol because the memory works with it....Then you recommend that i must to work with the same procotol....and that means that i have to work both (rf and memory) with i2c protocol..

Ok, that would be an option thanks :D

Another options ??? :) i want to know all the alternative.
By brennen
#20566
Then you recommend that i must to work with the same procotol....and that means that i have to work both (rf and memory) with i2c protocol..
This is not what I meant. I'm saying that there is a possibility that you can run both I2C and SPI on the same wires at the same time. The TRW will not interface to I2C directly as it has an SPI-type interface. Therefore, I would suggest just giving it a try by hooking both up at the same time and seeing if they work. The thing I would be careful with (as I mentioned before) is to make sure that when you send SPI data that there is a way to keep the I2C memory from interpreting it as a command (as in some sort of enable/disable pin on the memory chip).

If something goes wrong, you can always just sample another PIC from microchip. :twisted:
By vane_caracas
#20570
Hi brennen, thanks for your answer :D just a minute before read your answer i found in another place that is not a problem work with both protocols... :) the dispositive i2c always must be waiting for a start condition to do something... :wink: so i think that i dont have a problem anymore :mrgreen:

:? well i have to prove it

Thank very much :wink: