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


1 Answer 1


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.

  • \$\begingroup\$ So do you mean that I can re-use the line for data and clock for the SPI as well? \$\endgroup\$ Commented Jun 19, 2015 at 11:47
  • \$\begingroup\$ I've shared pins between I2C and a UART on a PIC12F, so it could be possible for you to share between I2C & SPI. But it depends on your circuit & peripherals. \$\endgroup\$
    – brhans
    Commented Jun 19, 2015 at 12:04
  • \$\begingroup\$ Not possible with SD card SPI at reasonable speeds. You want some MHz there, e.g. for finding the next free block in the FAT. \$\endgroup\$
    – Turbo J
    Commented Jun 19, 2015 at 17:37
  • 1
    \$\begingroup\$ Note that the SPI master required to talk to an SD card is relativly simple to implement in software, so you don't need hardware SPI, only 4 GPIOs. \$\endgroup\$
    – Turbo J
    Commented Jun 19, 2015 at 17:45
  • \$\begingroup\$ What if I shared the clock and data lines between I2C and SPI and do the following: OpenI2C(parameters); . . . CloseI2C(); OpenSPI(parameters); . . . CloseSPI(); Is this still not going to work? \$\endgroup\$ Commented Jun 20, 2015 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.