View previous topic :: View next topic |
Author |
Message |
fr3nsis
Joined: 13 May 2013 Posts: 10
|
mixing i2c and spi |
Posted: Fri May 17, 2013 2:07 pm |
|
|
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: 19590
|
|
Posted: Fri May 17, 2013 2:34 pm |
|
|
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
|
|
Posted: Fri May 17, 2013 11:44 pm |
|
|
thanks
which pic i can use? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19590
|
|
Posted: Sat May 18, 2013 1:08 am |
|
|
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
|
|
Posted: Sat May 18, 2013 10:34 am |
|
|
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
|
|
Posted: Sat May 18, 2013 11:35 am |
|
|
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 |
|
|
|