I2C-to-SPI bridge and SD card

i2cpicsdspi

I am using a PIC18F25k80 microprocessor, which is communicating by using I2C protocol with peripheral ICs. After collecting the data from the ICs I want to store them in an SD card. However for the SD card I need to transfer the data by using an SPI protocol, since it cannot operate with a low data transfer protocol. For that reason I put an I2c-to-SPI bridge (SC18IS602BIPW) on the bus. By writing the address of the interface bridge, followed by a 0 (control bit / write), on the I2C bus you can communicate with it. After the address a predefined function needs to follow (the functions are explained inside the datasheet) and then a series of data, which can be 0-200 bytes long. The data is stored in a buffer inside the interface bridge chip and then are automatically sent over SPI to a device. The predefined function determined the chip select bit and thus, the device with which the bridge is communicating.

I want to initialise a file system on the SD card, so that I can create files where my data is going to be stored. How can I use the function inside the FSIO.h in order to do that. Do I need to send the functions over the bus to the SD card and if yes how can I do that?

Interface Bridge datasheet:
http://www.nxp.com/documents/data_sheet/SC18IS602B.pdf

Best Answer

You will struggle to make this system work. An SD card offers a block-structured file system, which requires writes of full blocks of at least 512 bytes. Your bridge only supports 200-byte blocks.

Also the slow speed of I²C will give you trouble. Transferring 512 bytes over the 400 kbit/s I²C link will take approximately 10 ms.

Finally, you will need to write a software driver layer to drive the SD card through the bridge. This will take a lot of effort.

I notice the PPC18F2580 has an SPI interface. You should use the SPI interface to talk to the SD card and use the I²C interface to talk to the sensors. There should not be a need for the bridge.