SPI to I2C protocol converter  - Page 1
Forum section: electronics / beginners

author: joniengr081
author_rank: Regular Contributor
timestamp: February 28, 2024, 03:06:33 pm
content: Hello, I have used USB to UART and also USB to I2C protocol converter using MCP2221.I am now looking for another protocol converter for SPI. We are working on a new design. All the digital chips have I2C to communicate with microcontroller. There is one chip with SPI interface and the problem is that we can not have more wires between the microcontroller board and the new design because of other limitations.Option 1 is to find and other components which seems to be difficult because the components selection is already done and this component satisfy the requirements and it's difficult for a moment to open the discussion for replacement.Option 2 is to convert SPI to I2C using protocol converter if that exist. I am not sure if that is possible.

author: Perkele
author_rank: Regular Contributor
timestamp: February 28, 2024, 03:31:19 pm
content: Option 3 is to get a compatible microcontroller or a microcontroller board with more interfaces.

author: newbrain
author_rank: Super Contributor
timestamp: February 28, 2024, 04:11:08 pm
content: Something exists, not really cheap and not currently in stock at Mouser.https://www.mouser.se/datasheet/2/302/SC18IS606-2933187.pdfDepending on the needed speed, you might just add a 4 bit I2C expander and bit bang SPI...

author: joniengr081
author_rank: Regular Contributor
timestamp: February 28, 2024, 04:19:17 pm
content: Actually, we can not add another communication interface. There are cabling limitations.

author: joniengr081
author_rank: Regular Contributor
timestamp: February 28, 2024, 04:21:13 pm
content: Kindly explain little more, 4 bit I2C expander.

author: pcprogrammer
author_rank: Super Contributor
timestamp: February 28, 2024, 04:38:16 pm
content: He probably is talking about something likethis I2C chipwhich you connect to your existing I2C bus and then use the 4 IO pins to make a SPI bus with SCK, MOSI, MISO and CS. (Chip Select)You would have to send a lot of data over the I2C bus to transmit or receive a single 8 bit value from your SPI device, so it will be rather slow.With this you have to toggle the SCK output by sending specific data for it over the I2C bus, and also setup MOSI and CS as needed. For reading MISO you have to do it at the appropriate time after the clock change.

author: joniengr081
author_rank: Regular Contributor
timestamp: February 29, 2024, 06:57:59 am
content: Yes something like that. Four wires to two wire.We have an FPGA board which is I2C master. There are only two wires between FPGA board and the control board. On the control board, we have some ICs having I2C interface for communication to FPGA. We found a chip which I think meet all the other requirements and we would like to use that chip. The problem is that this new chip has SPI interface. The chip needs to be on the control board.

author: Ian.M
author_rank: Super Contributor
timestamp: February 29, 2024, 08:40:20 am
content: Having SPI only, makes the chip you've found impractical. Find another chip, with an I2C interface. If that's actually impossible (not just difficult or slightly expensive), another option would be a small, probably 8 bit, MCU with I2C (slave) and SPI interfaces, programmed to manage the chip you found and present a simplified I2C register interface to it.

author: newbrain
author_rank: Super Contributor
timestamp: February 29, 2024, 09:38:26 am
content: Quote from: pcprogrammer, snipped by me on February 28, 2024, 04:38:16 pmYes, exactly - thanks, I was away from a real keyboard.I have done that as I was in the same situation of the OP:- did not want to bring two different I/F to the board- I2C used by all the controlled chips- a port extender was already needed, and hade enough free pins- I only needed to write to an SPI-like controlled RF attenuator, at a leisurly pace.I2C-SPI bridges chips exist, such as the one I linked to in my post, and they are a simpler solution though not cheap.For a cheaper way, there are small programmable devices (a full MCU as suggested by Ian.M might be too much?) that fit the bill.E.g.https://www.renesas.com/us/en/document/apn/cm-334-bidirectional-i2c-spi-bridgeStill, if a native I2C solution can be found that's the best way.

author: cosmicray
author_rank: Frequent Contributor
timestamp: February 29, 2024, 11:11:55 am
content: Quote from: Ian.M on February 29, 2024, 08:40:20 amSome of the PUYA chips can handle that role. Cost is quite low, but would require some software dev to make it happen.

author: dobsonr741
author_rank: Frequent Contributor
timestamp: March 01, 2024, 02:55:14 pm
content: As well as an STM8L001. Many choices from safe supply chain backed vendors, with HW I2C slave and SPI. 500 lines of code and you are done. Assuming programming the MCU in circuit is not a problem.

author: joniengr081
author_rank: Regular Contributor
timestamp: March 20, 2024, 09:06:30 am
content: I found this device NXP SC18IS606PWJ which act as I2C to SPI converter/bridge. I was looking for such device.Now the FPGA/Microcontroller board will communicate through I2C with NXP SC18IS606PWJ physically located on the Control board together with some other I2C devices on the Control board. The FPGA/Microcontroller will act as I2C master and the NXP SC18IS606PWJ will be I2C slave on the Control board. The NXP SC18IS606PWJ have SPI interface on the other end which will be connected to the chip having SPI interfacehttps://www.farnell.com/datasheets/3685598.pdfThe problem was that we could not add more wires between FPGA/Microcontroller board and the Control board.

author: DavidAlfa
author_rank: Super Contributor
timestamp: March 20, 2024, 10:13:31 pm
content: And there's no i2c alternative part?