News for hackers. Stuff that matters.
Re:How many Devices can you Connect to the I2C Bus? by syntaxing on Tuesday April 13, 2021 @09:27AM (#26791840)
Interesting, is the pullup resistor common for other protocols like SPI?
Re:How many Devices can you Connect to the I2C Bus? by magicsmoke on Tuesday April 13, 2021 @09:47AM (#26792056)
The pull-up resistor allows I2C to have multiple masters on the same bus. A master take control of the bus by pulling either sck or sda low (can't remember which) and if other masters detect a low voltage when it expects a high it knows the bus is currently taken. SPI only has one active master on the bus at a time, so there's no need for pullup resistors to implement this arbitration mechanism. SPI masters just drive their bus lines using push-pull outputs.
Re:How many Devices can you Connect to the I2C Bus? by el_isma on Tuesday April 13, 2021 @11:31AM (#26793634)
It's even cooler than that: it has collision avoidance. To start a transfer you drive the clock low. If both masters drive the clock low at the same time. Then they start driving SDA with the address. If at any point in time, the address you are trying to put in the bus is not there, you stop. This could happen if you try to drive a 1 and the other master does a 0 (since it's open collector, the 0 will win), and you know you couldn't put your '1' in the bus, so you shut up and let the other master carry on.
Re:How many Devices can you Connect to the I2C Bus? by jeff_ciesielski on Tuesday April 13, 2021 @09:44AM (#26792029)
I hate to give an 'it depends', but it depends.

Typically, no. In SPI all lines are actively driven high or low rather than an open drain configuration. The bus master drives SCK (SPI clock), MOSI (master out, slave in) and CS (chip select), and the slave device(s) drive the MISO (master in, slave out) line(s). From an operating perspective, pullup/pulldown resistors are not required.

Now having said that, in some cases it's considered appropriate to add weak pullup/pulldown resistors to the data lines to ensure that they're in the expected state on power up and to prevent glitches from putting slave devices into weird states.

Re:How many Devices can you Connect to the I2C Bus? by monocasa on Tuesday April 13, 2021 @12:39PM (#26795051)
Three wire SPI is pretty common where everyone's MOSI and MISO are connected together open drain style, and the master clocks out 1s to let the slave pull the data line down for read operations. You have clock out something from the master during 4 wire SPI read anyway so it doesn't change a lot most of the time.
Re:How many Devices can you Connect to the I2C Bus? by analog31 on Tuesday April 13, 2021 @10:13AM (#26792398)
It's worth noting that I2C dates back a long ways, when we were still doing a lot of things like TTL, and weird asymmetric termination circuits were the norm. And it was under patent for a long time, so its development was stunted, and a lot of people used I2C peripherals by bit-banging GPIO pins with primitive code.

Virtually all SPI devices that I know of are CMOS with push-pull outputs and high-impedance inputs, which are much more friendly to work with. Until you try to drive the bus with two devices by accident. See my other comment about series resistors. I have a circuit right now that's operating a SPI bus with a 100 MHz clock on a small two-layer board and I'm getting away with it. A real engineer wouldn't allow this, but it's strictly for a research project.

Re:How many Devices can you Connect to the I2C Bus? by mindentropy on Wednesday April 14, 2021 @07:11AM (#26805481)
Also series resistors are used to prevent ringing etc acting as a termination resistor.