Functional Description
1506
SLAU723A – October 2017 – Revised October 2018
Copyright © 2017–2018, Texas Instruments Incorporated
1-Wire Master Module
22.3.5 Command Protocol
The standard 1-Wire protocol has commands to be used after a reset. These commands normally include
slave selection and detection. However, many 1-Wire buses only have one slave, and in that case, those
mechanisms can be skipped. If slave management is needed, a small software stack can be used to
handle these operations. Other protocols can also be easily supported, whether byte-oriented (as normal)
or bit-oriented. To support an alternative protocol, it is usually necessary to override some or all of the
timing and may be necessary to disable the answer-to-reset mechanism using the SKATR bit in the
ONEWIRECS register. The module is designed to support the most common uses of 1-Wire, including a
mechanism to allow a reset followed by an operation of 1, 2, 3, or 4 bytes through the SZ bit in the
ONEWIRECS register. Additionally, the OP bit supports a write/read model to allow a mix of write and
read in one transaction. Although nominally mixed mode allows for a mix of write and read bytes, it can be
used down to the bit level.
The following represents some typical operation flows:
1. To only send a reset, the RST bit of the ONEWIRECS register is set, performing a reset and triggering
an interrupt if enabled. If there is no answer-to-reset, the NOATR status bit is set and the
corresponding interrupt bit can be set as well.
2. The SZ and OP fields of the ONEWIRECS register are used to perform a write, a read, or a
combination. For small transactions, the SZ encoding can be programmed for processing of up to 4
bytes in one transaction. For larger transactions, the OP field can be used multiple times. The OPC
raw interrupt bit is used to notify when a transaction is complete.
3. To perform a reset and then a transaction, both the RST and OP and SZ fields of the ONEWIRECS
register are configured. The reset runs to completion and then the transaction starts. The interrupt is
used to notify when both are done.
To setup a read, write or mixed transaction, the following configuration must occur:
•
For writes, the 1-Wire Data Write (ONEWIREDATW) register must first be written with one, two, three
or four bytes to send (as a word). Next the ONEWIRECS register is configured as described above.
•
For reads, the ONEWIRECS register is written as described above. Then, when the transaction is
complete, the 1-Wire Data Read (ONEWIREDATR) register is read to collect the one, two, three, or
four bytes that were received (as a word).
•
For a R/W combination, the ONEWIREDATW register is written with one, two, three or four bytes to
write or read. Then, the ONEWIRECS register is configured as described above. As the data is
transferred from the ONEWIREDATW register to the 1-Wire line, any 1 that is transmitted creates a
read that is registered in the ONEWIREDATR register. When the entire transaction is complete, the
ONEWIREDATR register can be read to collect the bytes that were received by the 1-Wire Master. A
ONEWIREDATR register bit contains a 0 for any bit that was written as a 0, a 1 for any bit that was
written as a 1 or any bit not modified by the slave (may have been intentional 1 or ignored) and a 0 for
any bit written as a 1 but read back as a '0.'
22.3.6 Search (Enumeration) and Sub-Byte
Although 1-Wire is a byte protocol, there are times when less than a byte must to be written or read. By
programming the BSIZE field of the ONEWIRECS register, the number of bits to write and or read in the
last byte can be configured. The BSIZE field can be used for a 1-Wire search (enumeration) to allow
detect and select processing. Enumeration begins by executing the standard SEARCH (0xF0) command
(and if available, the ALARM SEARCH (0xEC)) and then reading two bits for the ID, which is the first bit
and its complement. Subsequently, a bit is emitted to select devices with that first matching bit followed by
another read of two bits. This process is repeated for up to all 64 bits. To start over, a reset is used. In this
way, a tree of IDs can be broken down until one unique ID is left. This can be repeated for each device.
The BSIZE field can also be used for non-standard devices which do not fully follow protocol.