Author Topic: half-duplex SPI over two wires?  (Read 2702 times)

0 Members and 1 Guest are viewing this topic.

Offline exeTopic starter

  • Supporter
  • ****
  • Posts: 2647
  • Country: nl
  • self-educated hobbyist
half-duplex SPI over two wires?
« on: December 27, 2018, 11:33:20 am »
Hello!

I have a usual dillema: i2c vs SPI. I like SPI because it's simple, but it requires one or two extra wires. But for my project I don't need a full duplex communication. I wonder if anyone tried to do a half-duplex SPI with joint MOSI and MISO lines. Probably, some active switching is needed to devices do not talk to themselves.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10385
  • Country: nz
Re: half-duplex SPI over two wires?
« Reply #1 on: December 27, 2018, 11:45:29 am »
It would be easier to implement in hardware on mcu's that can assign MISO & MOSI to the same IO pin.
Then you could clock data one direction, stop, switch direction and clock a response back


On mcus that have fixed MOSI MISO pins you might be able to link MOSI and MISO together and then feed that off to the other device with its MOSI and MISO shorted as well.
You would need to actively prevent any output-to-output shorting by dynamically switching one of the outputs from 'Special SPI Function' back to GPIO as input.
« Last Edit: December 27, 2018, 10:59:04 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 
The following users thanked this post: exe

Offline fchk

  • Frequent Contributor
  • **
  • Posts: 279
  • Country: de
Re: half-duplex SPI over two wires?
« Reply #2 on: December 27, 2018, 11:54:43 am »
This configuration is often used with Microwire EEProms 93C46/56. Just have a look at datasheet from a network chip or an FTDI FT2232H. You will find that D and Q (MISO and MOSI) of the EEPROM are tied together, with an reistor in front auf the Q line.

Other example: TI TUSB2046B USB hub chip.
 
The following users thanked this post: exe

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17427
  • Country: us
  • DavidH
Re: half-duplex SPI over two wires?
« Reply #3 on: December 27, 2018, 01:23:11 pm »
I wonder if anyone tried to do a half-duplex SPI with joint MOSI and MISO lines. Probably, some active switching is needed to devices do not talk to themselves.

Some SPI devices explicitly support this mode of operation; MISO on the slave is tri-stated until the MOSI transaction is completed and then MISO drives the line so MOSI and MISO can be tied together.
 
The following users thanked this post: exe

Offline exeTopic starter

  • Supporter
  • ****
  • Posts: 2647
  • Country: nl
  • self-educated hobbyist
Re: half-duplex SPI over two wires?
« Reply #4 on: December 27, 2018, 02:15:03 pm »
Wow, thanks, guys! I thought this idea would be panned, but it's actually already implemented, cool! So, at least I don't feel silly to try it.

Just in case, my use case is to establish communication between two parts of a DIY keyboard. I wanted it to have a nice looks, so, I'm going to use ready-made 4-wire cables, either TRRS or RJ9. Too bad I didn't find nice curly cables with plugs and sockets for 5 or 6 pins.

Although, chances are I'll end up with i2c because it's easier :). But for the sake of experiment I'll check SPI as well.
 

Offline fchk

  • Frequent Contributor
  • **
  • Posts: 279
  • Country: de
Re: half-duplex SPI over two wires?
« Reply #5 on: December 27, 2018, 02:56:44 pm »
Just in case, my use case is to establish communication between two parts of a DIY keyboard. I wanted it to have a nice looks, so, I'm going to use ready-made 4-wire cables, either TRRS or RJ9. Too bad I didn't find nice curly cables with plugs and sockets for 5 or 6 pins.

Although, chances are I'll end up with i2c because it's easier :). But for the sake of experiment I'll check SPI as well.

I2C is not meant for longer cables.

4 wires just call for UART transfer. Sun used UART for their SPARC UNIX workstation keyboards.

https://deskthority.net/wiki/Sun_Type_5
 
The following users thanked this post: exe

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17427
  • Country: us
  • DavidH
Re: half-duplex SPI over two wires?
« Reply #6 on: December 27, 2018, 05:08:46 pm »
If you have a choice, using UARTs over a half-duplex connection gets you down to one wire plus ground since no clock is required or two wires plus ground for full duplex.  This could be as simple as $1 PIC or AVR at each end converting SPI or whatever to asynchronous serial and doing any buffering and protocol tasks.

 
The following users thanked this post: exe

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4321
  • Country: us
  • KJ7YLK
Re: half-duplex SPI over two wires?
« Reply #7 on: December 28, 2018, 12:22:29 pm »
By coincidence, Google has been throwing adverts at me for the last month for the Analog Devices LTC4331



https://www.analog.com/en/products/ltc4331.html#product-overview

Is it worth switching to I2C?
 
The following users thanked this post: exe


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf