Author Topic: SPI to I2C protocol converter  (Read 905 times)

0 Members and 1 Guest are viewing this topic.

Offline joniengr081Topic starter

  • Regular Contributor
  • *
  • Posts: 159
  • Country: no
SPI to I2C protocol converter
« on: February 28, 2024, 03:06:33 pm »
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.
 

Offline Perkele

  • Regular Contributor
  • *
  • Posts: 50
  • Country: ie
Re: SPI to I2C protocol converter
« Reply #1 on: February 28, 2024, 03:31:19 pm »
Option 3 is to get a compatible microcontroller or a microcontroller board with more interfaces.
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: SPI to I2C protocol converter
« Reply #2 on: February 28, 2024, 04:11:08 pm »
Something exists, not really cheap and not currently in stock at Mouser.
https://www.mouser.se/datasheet/2/302/SC18IS606-2933187.pdf

Depending on the needed speed, you might just add a 4 bit I2C expander and bit bang SPI...
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline joniengr081Topic starter

  • Regular Contributor
  • *
  • Posts: 159
  • Country: no
Re: SPI to I2C protocol converter
« Reply #3 on: February 28, 2024, 04:19:17 pm »
Actually, we can not add another communication interface. There are cabling limitations.
 

Offline joniengr081Topic starter

  • Regular Contributor
  • *
  • Posts: 159
  • Country: no
Re: SPI to I2C protocol converter
« Reply #4 on: February 28, 2024, 04:21:13 pm »
Kindly explain little more, 4 bit I2C expander.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3710
  • Country: nl
Re: SPI to I2C protocol converter
« Reply #5 on: February 28, 2024, 04:38:16 pm »
He probably is talking about something like this I2C chip which 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.

Offline joniengr081Topic starter

  • Regular Contributor
  • *
  • Posts: 159
  • Country: no
Re: SPI to I2C protocol converter
« Reply #6 on: February 29, 2024, 06:57:59 am »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: SPI to I2C protocol converter
« Reply #7 on: February 29, 2024, 08:40:20 am »
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. 
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: SPI to I2C protocol converter
« Reply #8 on: February 29, 2024, 09:38:26 am »
...
Yes, 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-bridge

Still, if a native I2C solution can be found that's the best way.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline cosmicray

  • Frequent Contributor
  • **
  • Posts: 308
  • Country: us
Re: SPI to I2C protocol converter
« Reply #9 on: February 29, 2024, 11:11:55 am »
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.
Some of the PUYA chips can handle that role. Cost is quite low, but would require some software dev to make it happen.
it's only funny until someone gets hurt, then it's hilarious - R. Rabbit
 

Offline dobsonr741

  • Frequent Contributor
  • **
  • Posts: 674
  • Country: us
Re: SPI to I2C protocol converter
« Reply #10 on: March 01, 2024, 02:55:14 pm »
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.
 

Offline joniengr081Topic starter

  • Regular Contributor
  • *
  • Posts: 159
  • Country: no
Re: SPI to I2C protocol converter
« Reply #11 on: March 20, 2024, 09:06:30 am »
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 interface

https://www.farnell.com/datasheets/3685598.pdf

The problem was that we could not add more wires between FPGA/Microcontroller board and the Control board.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5912
  • Country: es
Re: SPI to I2C protocol converter
« Reply #12 on: March 20, 2024, 10:13:31 pm »
And there's no i2c alternative part?
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf