Electronics > Beginners

half-duplex SPI over two wires?

(1/2) > >>

exe:
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.

Psi:
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.

fchk:
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.

David Hess:

--- Quote from: exe on December 27, 2018, 11:33:20 am ---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.
--- End quote ---

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.

exe:
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.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod