half-duplex SPI over two wires? - Page 1
Forum section: electronics / beginners

author: exe
author_rank: Unknown
timestamp: December 27, 2018, 11:33:20 am
content: 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.

author: Psi
author_rank: Super Contributor
timestamp: December 27, 2018, 11:45:29 am
content: 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 backOn 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.

author: fchk
author_rank: Frequent Contributor
timestamp: December 27, 2018, 11:54:43 am
content: 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.

author: David Hess
author_rank: Super Contributor
timestamp: December 27, 2018, 01:23:11 pm
content: Quote from: exe on December 27, 2018, 11:33:20 amSome 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.

author: exe
author_rank: Unknown
timestamp: December 27, 2018, 02:15:03 pm
content: 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.

author: fchk
author_rank: Frequent Contributor
timestamp: December 27, 2018, 02:56:44 pm
content: Quote from: exe on December 27, 2018, 02:15:03 pmI2C 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

author: David Hess
author_rank: Super Contributor
timestamp: December 27, 2018, 05:08:46 pm
content: 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.

author: Richard Crowley
author_rank: Super Contributor
timestamp: December 28, 2018, 12:22:29 pm
content: By coincidence, Google has been throwing adverts at me for the last month for the Analog Devices LTC4331https://www.analog.com/en/products/ltc4331.html#product-overviewIs it worth switching to I2C?