1
\$\begingroup\$

I've read several different documentation sources explaining how Apple's asynchronous ADB protocol works. Although quite convoluted, it makes some sense of several rereads. I am having difficulty wrapping my head around how ADB's collision resolution works. This protocol is ancient and no longer used, but perhaps someone with a fresh mind can parse the documentation better than me.

https://developer.apple.com/library/archive/technotes/hw/hw_01.html#Section2

First, during the device address resolution (device enumeration) the ADB Manager polls devices and the devices are responsible for detecting collisions. When a device responds, it is supposed to supply a "random" address to the ADB Manager. It's unclear how this random address factors into the address resolution. Specifically, here's what it says the ADB Manager does:

An ADB device's register 3 is 2 bytes long, and includes 4 bits in which the address is stored. When the device receives a listen register 3 command, it should take its address from this 4-bit field. When it receives a talk register 3 command, it would be redundant to put the device's address in that field: the device's address is already uniquely determined by the fact that the device is responding to the talk register 3 command, which was sent to a specific address. Instead, a random 4-bit value should be returned in this field; this makes it easier to detect collisions between two devices responding to a talk register 3.

It only says "it makes it easier to detect collisions." There's no further discussion about how it uses this address to determine a collision. Microchip's technote AN591, says the device is responsible, but it is still unclear:

When a device recognizes that the Host issued a “Talk Register 3” command, it responds by sending a random address. During the transfer of each Bit Cell of the random address the signal line is monitored for the expected signal level. If the signal is not what is expected there is an address conflict. If the address is sent successfully, the host will respond with a Listen Command to that device. The command will have a new Device Address to which that device will move. The device then only responds to commands at the new address. If there is a conflict, where two devices have the same default address, and respond at the same time, the device that finds the line low when it expects it to be high, immediately stops transmitting because it has determined that a collision has occurred.

Given this is an asynchronous operation, it's impossible to read the ADB signal while writing a signal.

Second, ADB is supposed to support up to 16 devices since the device address is 4 bits. During the device resolution, however, addresses $8-$F are used for address resolution. This means there can be a maximum of 8 devices of a specific device family, not 16? Am I correct here?

\$\endgroup\$
6
  • \$\begingroup\$ Assume there is a collision and two remote devices send an address back. If they used the address sent then they would be indistinguishable, if they send back a random address that is not the original probe, then you may be able to distinguish the collision (as long as they don't both send the same random address). \$\endgroup\$ Commented Jun 29, 2018 at 18:19
  • \$\begingroup\$ @JackCreasey. I updated my question with more details. The documentation is very confusing. How is it possible to read a signal and write a signal, especially when it's asynchronous. \$\endgroup\$
    – user148298
    Commented Jun 29, 2018 at 19:33
  • \$\begingroup\$ OF course you can read and write at the same time. They are checking bit times on the line. The target writes the value to the line bit by bit, and monitors that if it wanted to send a '1' a '1' arrives on the line. If it wanted to send a '1' bit, but detected a '0' or vice-versa than it know someone else is also writing to the line. Hence it know thare is a collision. \$\endgroup\$ Commented Jun 29, 2018 at 20:19
  • \$\begingroup\$ OK. I see now. So writing to a line is not momentary. It can be toggled. Thanks. One addendum. The documentation mentions open collector, but and Microchip mentions tristating the pins. Does this mean you can read a no value? \$\endgroup\$
    – user148298
    Commented Jun 30, 2018 at 1:09
  • \$\begingroup\$ Also, the random address isn't really an address, but just a random token which is used for bit testing. I must say the terminology used in the protocol takes some liberties in its definitions. Thanks for clearing it up for me. \$\endgroup\$
    – user148298
    Commented Jun 30, 2018 at 1:14

1 Answer 1

0
\$\begingroup\$

It's in the second paragraph.

Because the ADB bus is open collector, collisions can be detected when a device is attempting to drive the bus high and another device pulls it low. This means that whenever the device is driving the bus high, it should be watching to make sure the bus is actually high; if the bus goes low, some other device is sending at the same time. When a device detects a collision, it should immediately stop transmitting: this means that if two devices are colliding, one of them will detect the collision, while one will not. This occurs because a device can only detect the collision if it is driving the bus high and another device drives it low. The device driving it low has no way to tell that there was a collision, as the bus follows it. Since the detecting device immediately stops transmitting, the other device will not detect the collision. Thus, if there are a number of devices transmitting on the bus, only one of them will complete its transmission without detecting the collision, unless the unlikely occurrence of more than one device transmitting exactly the same data with the same timing occurs, and neither detects the collision.

Open collector means the device makes the bus voltage go low by actively conducting current to ground, but lets a resistor make it go high, thus when any device is not commanding the bus low, but letting it rest high it can monitor the bus to see if another device is using it.

Two devices who have taken the same address when commanded to return register 3 will by returning a random number instead of an address (which would match exactly) have a chance of disagreeing on the random number and thus one of them will detect the collision.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for your answer. I figured it out. What threw me for a loop was the "random address" term. It turns out the random address serves a couple of purposes other than what it is named. It is not an address that's used for identifying the device. \$\endgroup\$
    – user148298
    Commented Aug 9, 2018 at 14:48
  • \$\begingroup\$ It's actual purpose is to generate a random a stream of bit patterns. All the devices with the same default address send out a random bit and then check if the bus is in the same state. If not, it means another device is sending data, meaning there is an address collision. The documentation could have clarified this a lot better. Documentation should be written by throwing it over a wall just like reverse engineering patented algorithms. \$\endgroup\$
    – user148298
    Commented Aug 9, 2018 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.