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

mixing i2c and spi

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fr3nsis



Joined: 13 May 2013
Posts: 10

View user's profile Send private message

mixing i2c and spi
PostPosted: Fri May 17, 2013 2:07 pm     Reply with quote

I would to make a system (logger) that read rfid tag and store on sd card tag id and date/time.
I connect succesful rfid reader via i2c and can read/write card and show data on lcd.
On i2c is connected also one ds1307
Can be problem if i'll try to connect an sd card on spi bus using a level shifter like 4050 ? They are never active at same time.
16f877a has enough ram for this ?
On sd card must be only 1 file txt with:

tag date time
tag date time
tag date time
.....
Ttelmah



Joined: 11 Mar 2010
Posts: 19589

View user's profile Send private message

PostPosted: Fri May 17, 2013 2:34 pm     Reply with quote

Just use software I2C on different pins.
You can't mix the busses together, SPI is hardware driven high/low, while I2C, uses open collector drives.
No the 16F877 does not really have enough RAM. Writes to SD cards are in 512byte blocks....

Best Wishes
fr3nsis



Joined: 13 May 2013
Posts: 10

View user's profile Send private message

PostPosted: Fri May 17, 2013 11:44 pm     Reply with quote

thanks
which pic i can use?
Ttelmah



Joined: 11 Mar 2010
Posts: 19589

View user's profile Send private message

PostPosted: Sat May 18, 2013 1:08 am     Reply with quote

Realistically, any PIC with at least 768bytes RAM.
However if you have PCH, go for something that has dual MSSP ports, then you can have hardware for both ports.
Really depends how many pins you need, and what else you are doing. Chips like the PIC18FxJ50 make the SD card interface easy (3.3v operation). Use the DS1338, instead of the 1307 (also 3.3v), and you've suddenly got rid of a lot of complexity, and given yourself a huge amount more ROM/RAM.

Best Wishes
fr3nsis



Joined: 13 May 2013
Posts: 10

View user's profile Send private message

PostPosted: Sat May 18, 2013 10:34 am     Reply with quote

atm here i have some 18f2550 (also l version) and some 18f2458.
I'm trying to do something with those before to buy new one.
Problem is that anyway i have:

rfid that with i2c connection that works with vcc from 4,5 to 5,5
ds1307 with i2c connection that works with vcc from 4,5 to 5,5
sd card with spi connection at 3,3v

So also using 3,3v pic i must use some level shifter for i2c or i'm wrong?
my idea atm is this:

pic powered at 5v
use ra0/1/2/3/4/5 with lcd (rs,en,d4-d7)
rc0,rc1,rc2 for led and buzzer
rc7,rb0,rb1,rc6 for spi using 74hc4050 like level shifter
3,3v taken from regulator 5v->3,3v
temtronic



Joined: 01 Jul 2010
Posts: 9270
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat May 18, 2013 11:35 am     Reply with quote

should be ok but...

do ALL the SD card code FIRST !!
get it up and running 100% BEFORE the rest.
use a proper 'level shifter' for the SD card and run PIC and rest at 5 volts.

Everything else is super easy.

hth
jay
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