CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

spi and i2c question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
x!nDy
Guest







spi and i2c question
PostPosted: Tue Feb 09, 2010 12:10 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 09, 2010 3:11 am     Reply with quote

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







PostPosted: Tue Feb 09, 2010 4:18 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 09, 2010 2:32 pm     Reply with quote

Here are several topics that discuss using SPI and i2c on the same pins.

Can #use i2c() be used with #int_ssp for SPI?
http://www.ccsinfo.com/forum/viewtopic.php?t=39231

I2C and SPI on one chip
http://www.ccsinfo.com/forum/viewtopic.php?t=36890

Not able to re-enable I2C interrupts after using spi.
http://www.ccsinfo.com/forum/viewtopic.php?t=34401

SPI AND I2C AND RS232 all together?
http://www.ccsinfo.com/forum/viewtopic.php?t=33732

Can SPI and I2C devices co-exist on the same pins? (Has several links)
http://www.ccsinfo.com/forum/viewtopic.php?t=30553
Ttelmah



Joined: 11 Mar 2010
Posts: 19546

View user's profile Send private message

PostPosted: Sat Aug 30, 2014 1:30 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group