1-Wire Bus Commands: Having seen the timing details for the 1-Wire bus, let’s now examine the data content during communications. We’ve made note of the fact that 1-Wire devices are individually selectable, can respond to commands, and that there are some commands that are common to most devices. We’re going to take a look at some of these common commands now. The commands that are common to most devices are known as the ROM commands, because they deal with reading the device’s 64-bit ID ROM. These four commands are the Read ROM, Search ROM, Match ROM, and Skip ROM. Each is an 8-bit command, meaning that in order to invoke this command, the bus master writes the 8-bit command to the 1-Wire bus.
The best way to learn this stuff is to go through a real example, with a real device. We’ll use the simplest device of all: the DS2401 Silicon Serial Number. We noted earlier that 1-Wire devices all have a unique 64-bit ID consisting of an 8-bit family code byte, a 48-bit unique serial number, and an 8-bit CRC byte. This ID code is used to select the device, which, once selected, responds to commands and normally performs some sensing or actuating function and responds with data. The DS2401 is nothing more than the 64-bit ID. It has no other function. It’s the most basic of 1-Wire devices, and is literally a silicon serial number. It comes in a variety of packages, but always utilizes just one signal and one ground connection. Let’s see how this device works by looking at the DS2401 command flow chart, like those provided by Dallas Semiconductor in their data sheets2. The DS2401 command flow charts discuss only the Read ROM command and the Search ROM command. This is because the device is so simple it only needs two of the four commands that are commonly shared by all 1-Wire devices and no function-specific commands. This will make more sense as we delve into it a little deeper.
Figure 10-8: DS2401 package styles, pin-outs
As shown in the flow chart (Figure 10-9), the process begins with the bus master issuing a reset by pulling the bus low for a period > 480 µs, and then releasing the bus to be pulled high. When the DS2401 sees the reset pulse, it waits at least 15 µs but less than 60 µs, then responds with a presence pulse, which is at least 60 µs but less than 240 µs. After this sequence of events, the 1-Wire bus protocol specifies that the 1-Wire slave devices are all waiting for an 8-bit command. In the case of the DS2401, there are only two commands that we can give it: Read ROM (0×0F) and Search ROM (0xF0).