For a more complete understanding, reference is now made to the following description taken in conjunction with the accompanying Drawings in which:
Referring now to the drawings, wherein like reference numbers are used herein to designate like elements throughout, the various views and embodiments of a system and method for operating a two-wire bus using a two-wire protocol and a one-wire protocol are illustrated and described, and other possible embodiments are described. The figures are not necessarily drawn to scale, and in some instances the drawings have been exaggerated and/or simplified in places for illustrative purposes only. One of ordinary skill in the art will appreciate the many possible applications and variations based on the following examples of possible embodiments.
Referring now to the drawings, and more particularly to
By utilizing a one-wire protocol operating within the normal constraints of the I2C communications protocol, devices connected to the I2C communication bus 110 consisting of the S-data line 106 and S-clock line 108 may communicate over the I2C bus 110 using the two-wire I2C protocol with either a one-wire communication mode interface 112 requiring only the S-data line 106 or a two-wire communication mode interface 114 using both the S-data line 106 and S-clock line 108. While each of the master device 102 and slave devices 104 of
The two-wire communications mode interface 114 enables an attached device to operate over the I2C bus 110 using a synchronous communications mode of operation. While the present description is described with respect to the use of an I2C communications bus with a two-wire communications mode, other types of two-wire communications protocols with broadly similar signaling, may also be utilized such as SMBus or PMBus, for example. The one-wire communications mode interface 112 of each of the devices enables the use of a I2C bus having a synchronous protocol but using an asynchronous interface therewith.
With further reference to
The general overall operation of the I2C protocol is for the master 102 to generate a start bit, followed by a 7-bit or a 10-bit address to uniquely address one of the slaves. Each of the slave devices in a system normally has a unique address. Following the 7-bit or 10-bit address will be a single direction bit to determine whether this is a Read or a Write operation. Once the address and the direction bit have been read by the slave, a 1-bit field is provided to allow the slave to generate an acknowledge bit. The acknowledge bit is always generated by the receiving device such that, for a Read operation, an acknowledge bit will be generated by the master after it has received data from the slave.
From a communication stand point, the master 102 will treat every slave on the bus 110 equally; that is, it will generate an address and a clock signal regardless of whether a particular slave is operating in the one-wire mode or the two-wire mode because it cannot distinguish one-wire from two-wire. Thus, that particular slave, when operating in a one-wire mode, must be able to receive and transmit to the data bus as if it were in a synchronous mode of operation.
Referring now to
In order to interface with the data bus 106 (SDLA) or the clock line 108 (SCL), there are provided selected interfaces for both. Since this is a bidirectional data and clock lines, i.e., both the master and the slave can control the line, each has the ability to detect a low going signal or drive the line low, this being an open collector configuration with pull-up resistors 126 and 128, respectfully, associated with the respective SDA line 106 and SCL line 108. For the clock line, there is provided a receive buffer 130 for receiving the clock signal and providing its output on a line 132 and also an NPN transistor 134 with the collector thereof connected to the SCL line 108 and the emitter thereof connected to ground. The clock line 132 will interface, in a two-wire mode, with a conventional two-wire interface 136. The two-wire interface 136 will receive the clock signal on the line 132 and derive its timing therefrom. For data transfer and for control of the SCL line 108 for some function such as clock stretching, the transistor 134 is controlled by the two-wire interface 136 to pull the SCL line 108 low by the slave. For data reception and data transfer, a buffer 138 is provided which is connected on one side to the SDA line 106 to provide a data output signal on line 140. To transmit data from the slave, an NPN transistor 142 having it emitter thereof connected to ground and the collector thereof connected to the SDA line 106 is provided with the base thereof controlled by the two-wire interface 136.
In operation, whenever the SDA line 106 is detected as going low on the line 140 by the two-wire interface 136 while the clock line 108 is high and then the clock line is detected as going low at a later time, this will indicate to the two-wire interface 136 the occurrence of a start signal for a two-wire communication. If the clock signal never goes low, i.e., because there is no clock signal attached, then this indicates a one-wire configuration wherein the SDA line 106 going low comprises the start signal. Of course, for this chip, there will be a requirement that the SCL line 108 input is pulled high at all times when in the one-wire mode. Thus, if a chip with a two-wire interface is placed into a one-wire system, i.e., a system without a clock line, it is necessary to pull that input high. However, if a clock is present on the SCL input, the two-wire interface 136 in the two-wire mode will be able to receive data and then transmit the data since it receives both input from the buffer 138 and is able to control the base of the transistor 142.
In the one-wire mode, a clock detect circuit 144 is provided to determine whether the clock line has gone low. If the data line goes low and the clock line does not go low, a one-wire interface 146 will then take control of the communication. When the data line goes low on line 140, the one-wire interface 146, as well as the two-wire interface 136, are both initiated. However, if a clock signal is detected, the one-wire interface 146 will be disabled, i.e., it will know that no information is to be transmitted thereto. This is only in the case where there is provided on the chip a two-wire interface and a one-wire interface function. If only a one-wire interface were provided, the one-wire interface 146 would always asynchronously decode the received address. The SCL pin is tied to open to indicate a one-wire mode.
The one-wire interface 146 contains a one-wire controller 150 and a free running oscillator 152, which is not synchronized with the master or with the clock signal on the SCL line 108. There is also provided a counter 154 which is operable to count the number of cycles of the oscillator 152 between successive edges of a data input during a synch operation. An address decoder 158 is provided which is operable to access an address memory 160 to compare the received address bits, decode those address bits and compare them to what is stored in the address memory 160. This address memory 160 is also utilized for the two-wire interface function 136. This address memory 160 provides the address for the device 120. As will be described hereinbelow, for a two-wire interface functionality, only a single unique address is provided for the device 120. In the instantiation described hereinbelow, the one-wire interface portion 146 mode requires two addresses, one for Write operation and one for Read operation. Thus, when the slave is synchronized and the address bits are extracted from the data stream, the address will determine whether data is to be transferred thereto or read therefrom. If a particular slave is bidirectional (R/W capable) this will require the master device 102 to view a particular slave device as actually two slave devices on the system, one for a data transmission operation and one for a data fetch operation.
Referring now to
Referring now to
Since the slave in a one-wire environment cannot receive a clock signal, the I2C protocol will not afford multiple data bytes to be transferred. Cumulative error will prevent this. In a conventional I2C protocol, the slave, after the ACK bit 214, can continue to transfer or receive data, depending upon the direction bit in field 210, if the stop bit has not been generated, which stop bit is a condition wherein the SDA line 106 makes a transition from a low to a high while the SCL line 108 is high. Thus, the SCL line 108 is pulled high before the SDA line is pulled high. Since the SCL line 108 is not available, this requires that the slave be able to detect the transition of the data line at a particular time relative to a predicted clock occurance and thus allow multiple bytes to be transmitted for either a Read or a Write operation.
Referring now also to
The above-described slave addressable format provides for separate Read and Write addresses as illustrated in
By forcing constraints on the allowable slave address ranges using the preamble 302 and post-amble 306, the protocol for the one-wire asynchronous communications may re-synthesize the rising edge of the S-clock signal in order to enable correct sampling of the S-data line 106. Thus, using the described scheme, the S-data line 106 is forced to provide the fixed preamble 302 to enable the generation of data timing at the beginning of every data transmission following the start condition 202. The use of the fixed post-amble 306 for a Read or Write operation on the s-data line 106 enables resynchronization of the system timing for the subsequent data byte field 206.
The preamble 302 and the post amble 306 in
For synchronization purposes, it is necessary to have somewhere within the address field two successive edges, a rising edge and a falling edge or, alternatively, a falling edge and a rising edge. From this information, the length of the SCL clock signal can be determined. Therefore, in the data stream, a “101” or a “010” must exist. In the disclosed embodiment, this is facilitated in the beginning of the clock cycle since the data line is pulled low followed by the address. Thus, there will be a “0” prior to the initiation of the 7-bit I2C address field. However, the length of time between the falling edge of data stream on the SDA line 106 indicating the initiation of a data transmission and beginning the of the I2C address field is not measured in terms of a single “bit time.” Rather, all that is ensured is that there will be a data low condition prior to the initiation of the I2C address field. By ensuring that the first bit in the address is a one, that will ensure that there is a first rising edge and then ensure that the next bit is a “0” will ensure a falling edge and this will enable measurement of time between two successive edges for a “010” condition. Note that, by placing this at the beginning of the address field, one fewer defined bit is required due to the fact that there is a known condition of the data low prior to initiation of the address. Thus, by fixing these two MSBs to a “10” state, only two bits are required for the synchronization process. These, of course, could be disposed within the middle of the I2C address field, and then all edges analyzed in the received signal. In the case where a second synchronizing operation is required prior to the data, there will be required three bits of address. This is the reason that for the Write operation and the Read operation requires a “010” or a “101” sequence, respectively. Thus, by providing a standard I2C address field (7-bit or 10-bit) followed by the direction bit and by ensuring that there are two successive rising/falling or falling/rising edges in the address field at some point therein, clock information can be extracted from the address field. This does not require additional synchronizing bits to be transmitted by the master prior to generating an I2C address field because, as stated hereinabove, the master has no knowledge that any portion of the I2C address is utilized for synchronizing purposes. It merely requests the master to generate the unique slave address that was fixed in its memory for that particular slave device in the course of the standard I2C protocol. It is the slave device to which the communication is directed that understands how to extract the 3-bit address and the timing information from the I2C address field, with the additional notation that the address space must be restricted. Thus, all addresses on the bus have a common “10” for the first two MSBs. But this restriction is merely between the devices that are attached to an I2C bus in which at least one of the devices operates in a one-wire mode of operation and only receives data and not clock information.
Referring now to
With respect to the Write data stream 502, this will be described initially. The data transfer operation is initiated by the SDA 106 falling low at an edge 505. This basically wakes the part up and indicates that the data transfer operation is to begin. The normal mode of operation with a clock line connected to the part in a normal two-wire I2C mode of operation and a clock line utilized for the data transfer would require a falling edge of the SCL 108 to occur after the falling edge 505. This is illustrated by an edge 507 of the regenerated local clock. Although this locally generated clock is illustrated as being accurate in time, it is not actually synchronized at this point in time. However, the falling edge 505 and the falling edge 507, in a normal two-wire mode of operation I2C format, would constitute the start bit. Since this is a one-wire transfer operation, only the falling edge 505 constitutes the start bit.
Once the falling edge 505 occurs, the system is initiated from a control stand point and awaits a next rising edge 509. This rising edge 509 occurs after the clock edge 507 and initiates a counter. A counter will count the number of cycles of a local oscillator (with higher frequency than the clock waveform 506) until the next falling edge 511. This is the reason that the first bit in the normal address field for the I2C protocol must be a “1” followed by “0.” Once the falling edge 511 occurs, timing information has been extracted from the sequence. Of course, this requires that a “0” be the next occurring bit after the MSB and this is a fixed requirement. Thus, the first two bits of the address, the first two MSBs, are dedicated to the synch field operation but, from the perspective of the master, this is still a slave address. This is illustrated with a circle 508 about these two bits.
Once the clock has been synchronized, then it is possible to ensure that the leading edge of the clock occurs at the appropriate bit position within a particular bit time. Thus, the next three address bits, A2, A3 and A4 can be read, this being in a region 510 in the bit stream. These constitute the slave addresses that are allowable with respect to the one-wire protocol. This will allow for eight different slaves to the addressed. Of course, it should be understood, that long address fields can be used in the initial protocol, such as for a 10-bit I2C protocol. It is only necessary that the first two bits be utilized for the synchronization operation and the last two bits be utilized for the subsequent post amble synch operation. In the Write operation, this is illustrated as being the bit sequence “010” which comprises the R/W bit in the two LSBs bits, a “0” and a “1”. Since the Write bit in the I2C protocol is required to be a “0,” then, in order to provide a synchronizing edge, the preceding two bits must be a “0” and a “1.” Thus, after the three address bits are read in the field 510, the first bit to be read will be a “0” for a Write operation. At this point in time, the one-wire interface interprets this as being a Write operation and then, at the next leading edge 513, starts the counter again until the next falling edge 515. This provides a refresh of the SCL clock cycle length and is utilized to adjust the internal bit clock, if necessary.
After the two LSBs and the R/W bit are read in the field 512, the next bit time is reserved for the acknowledgement signal, this being a field 516. This is one in which the slave generates the signal for transmission back to the master by pulling the SDA line 106 low. The detail of this is illustrated in
After the SDA line is pulled high during ACK bit 516, then one byte of data is transmitted by the master. The resynchronized clock can now sample each of these bits at the appropriate point until the end of a field 518. At the end of the field 518, the SDA line 106 will be pulled low for another acknowledgement bit 520. This is performed by the slave device in accordance with the timing diagram described hereinabove with respect to
The Read operation associated with the Read bit stream 504 is similar to that of the Write bit stream 502. It will be provided a falling data edge 531 from the master followed by the logic “10” bit sequence in a field 508 within the I2C address field for the synchronizing operation, followed by the three address bits in the field 510 within the I2C address field and then the sequence “101” for the Read sequence. In this sequence, the slave will sense the address bit Al and determine that it is at a logic level “1” which will indicate a Read operation. Even though the slave is aware there is a Read operation, it will then look for the next falling edge, falling edge 533, followed by rising edge 535 and use this to synchronize. This is the reason that there must be a “1” followed by a “0” followed by a “1.” Thereafter, an acknowledgement signal will be sent back in a field 516 followed by one byte of data in the field 518. Since this is a Read operation, the one byte of data is transferred from the slave to the master. Thus, at the end of the last byte of data in a field 518, there must be an acknowledgement received from the master in a field 522. In a field 522, the acknowledge from the master to the slave is slightly different in that the slave, after transmission of the last bit to the master, will then release the SDA line 106. The SDA line 106 goes high and then the master will pull the SDA line 106 low. The slave can see this operation. The master then places a clock pulse on the SCL line 108 and, after end of this pulse, releases the SDA line. What the slave will see is the SDA 106 go low and then high but will not see the clock pulse.
In generating the signals according to the described protocol, a number of presumptions are made that force the interface to operate in a manner that most users operate the I2C protocol, but allow the operation of a one-wire protocol. These presumptions include the S-data rise/fail times must be relatively close together since the S-clock period is measured from rise to fall. Additionally, the S-clock period does not accumulate an error (i.e., grow or shrink) during transmission between the start portion and the stop portion. Also, the delay from the S-clock falling edge to the S-data rising or falling edge is consistent and small (under 15 percent of the S-clock period). A minimum S-clock speed of 1 kilohertz is assumed to constrain the length of the counter used for a clock period measurement. Thus, using the above described technique, the S-clock timing may be determined by limiting the range of 256 read/write slave addresses to a few addresses that simplify the timing extraction. The process utilizes the falling edge of the S-data signal as the beginning of a one-wire communication.
Referring to
Next, the preamble consisting of the combination of the one bit and zero bit are transmitted at the step 604 as part of the I2C address field to enable initial synchronization of the asynchronous one-wire transmission for the slave address. The slave device address is then transmitted at step 606 from the master device over the I2C bus as part of the I2C address field to notify the slave device for which the data is addressed. Finally, the post-amble for either the Write or Read operation is transmitted at step 608 as part of the I2C address filed in addition to the direction bit to enable resynchronization for transmission of the data byte following the transmission of the address byte.
Referring now to
Once the preamble is detected, the timing for the address byte is established at step 708. The address associated with the addressable slave device is detected at step 710. After receipt of the address, the addressed slave device begins monitoring for the Read/Write post amble at inquiry step 712. Once the Read/Write post amble is detected at inquiry step 712, the timing is resynchronized at step 714 at the slave device for receipt of the data byte. The Read/Write data is transmitted over the I2C bus at step 716 in the appropriate direction, and a stop indication or a further start indication is detected at inquiry step 718, i.e., the end of the last bit of data. Upon determining that the last bit of data has been transmitted indicating a stop condition, the process is ended at step 720. If an additional start condition is provided, the process returns to inquiry step 706 to monitor for a new preamble.
The process for generating the timing signal for the address byte at step 708 or re-synchronizing the timing for the receipt of the data information at step 714 is more fully described with respect to the flow chart of
Upon detection of the rising edge at inquiry step 806, a counter within the detecting device is initiated at step 808. The device will then monitor at inquiry step 810 for the occurrence of a falling edge on the S-data line represented by the transmission of the next zero bit of the preamble. Upon detection of the falling edge on the S-data line, the counter is stopped at step 812. Utilizing the information within the counter and the known period of an internal clock, the S-clock signal may be generated for the transmissions at step 814. Using the internal clock and counter, the period of the S-clock may be determined from the rising edge of the S-data line and the falling edge of the S-data line since the one and zero bits are always transmitted as part of the preamble. One manner for synthesizing the S-clock signal is to run an internal high-speed clock oscillator having a much faster rate than the maximum S-clock signal that is expected. The counter then counts the number of periods of this clock that occur between the detected rising edge of the S-data line and the falling edge of the S-data line within the preamble. For low-power systems, the oscillator could be enabled upon the first falling edge of the S-data line providing a minimum of 600 nanoseconds to stabilize before the first rising edge of the S-data line. The oscillator may then be disabled outside of transmissions in order to save power.
The determination of the clock period for transmission of the data byte is determined in a similar manner responsive to the known rising and falling edges of the transmitted post-amble. Within the post-amble, the first bit of the post-amble indicates a Write operation or Read operation with the zero bit indicating a Write operation and a one bit indicating a Read operation. The last two one/zero bits of the Write post-amble may then be used to establish the timing for the data bit in the same manner that the one and zero bits of the preamble are used as described hereinabove. For a Read operation, the process works in a similar manner to that described with respect to the preamble but in an initial detection, and starting of the counter is made upon the detection of the falling edge of the zero bit and then the counter is stopped upon the rising edge of the one bit. The counter value and the known period of the clock is then used to determine the clock signal in a similar manner.
Referring now to
Referring further to
Referring now also to
Thus, using the above described system and method, communications may be carried out over a synchronous I2C bus using a synchronous two-wire I2C protocol with slave devices operating using an asynchronous one-wire protocol. The I2C signaling system remains unaltered, enabling existing hardware and software methods for generating I2C communications to continue to be used. By applying signals on the S-data line of the I2C bus including the above-described constraints, a mix of conventional I2C/SMBus devices and devices using the one-wire protocol as described herein may share the same bus.
As described above, each device on the bus must be individually addressed, i.e., each must possess a unique address with respect to its position on the I2C bus. If a seven bit address is utilized with a direction bit, this provides a total of eight bits which, as described hereinabove, are divided up such that three bits are true address bits uniquely identifying a device, the first two MSBs used for synchronizing the data portion and the last three LSBs utilized for the direction and for resynchronizing the one-wire slave for a data transfer. The second synchronization may not be necessary which may allow two additional bits to be provided for an address with a single direction bit. This would then provide for 32 unique addresses. However, in this situation, there would only be required a single address for a particular one-wire device for both the Read and the Write operations since the unique address is defined apart from the direction bit. This is compared to the first embodiment that required the post amble synchronization wherein the unique address plus direction bits generated by the master would have to take into account the synchronization aspect and, as such, two addresses would be required for each part, assuming that a particular part required both a Read and a Write operation. This may not be the case with respect to some parts that are unidirectional such as a DAC and an ADC.
If a 7-bit address I2C protocol were utilized with a single direction bit for either a preamble/post amble synchronization process or only a preamble synchronization process, the first two bits with a “10” logic state would have to be present for all devices, including the two synchronous I2C devices 902. The reason for this is that, even though a two-wire I2C slave device can recognize the first two bits as address bits because they use the S-clock signal for the bit clock, the one-wire slave device in an I2C environment would not be able to discern such and it could interpret, for example, an address with an address having the logic state “110xxxx” wherein the first two MSBs are “11” as being a single logic one and set the clock at a much lower rate than is actually present. Further, if the first two MSBs were a “00” followed by a “1” the one-wire slave would wait until the third MSB to initiate a determination of the clock duration. As such, the first two MSBs in this system would be lost to unique addresses overall slave devices. Thus, for a 7-bit address scheme with one direction bit but requiring a preamble and a post amble, there would only be eight unique addresses and, as such, there can either be eight one-wire devices with Read/Write capability, eight one-wire devices with Read direction only and sixteen with Write direction only or a combination of the one-wire devices with the I2C devices for the slaves.
Referring now to
With reference to
Referring now to
Referring now to
In the situation wherein at least one of the slave devices does not have access to the SCL line and thus must communicate with the one-wire protocol, then the address space for the entire system is restricted such that the first two MSBs are at a logic state “10.” When a system designer designs the system in which at least one slave device does not have access to the SCL line, it will be necessary to ensure that the slave devices are configured so that there is no overlapping of addresses in the address space. Further, in the event that there is a device that can be read from or written to, it is necessary to configure the master such that it perceives this single virtual slave device as being two slave devices by combining two addresses. Since the master views the unique address as defined by the 7-bit address space and a one-wire slave device can have two different I2C addresses in that space, i.e., “10xxx01”, the master must be programmed to consider a single slave device as two separate virtual devices.
Referring specifically to
It will be appreciated by those skilled in the art having the benefit of this disclosure that this system and method for operating an I2C using both a two-wire protocol and a one-wire bus provides more flexible uses for devices operation on an I2C bus. It should be understood that the drawings and detailed description herein are to be regarded in an illustrative rather than a restrictive manner, and are not intended to be limiting to the particular forms and examples disclosed. On the contrary, included are any further modifications, changes, rearrangements, substitutions, alternatives, design choices, and embodiments apparent to those of ordinary skill in the art, without departing from the spirit and scope hereof, as defined by the following claims. Thus, it is intended that the following claims be interpreted to embrace all such further modifications, changes, rearrangements, substitutions, alternatives, design choices, and embodiments.
This application claims priority to U.S. Provisional Application No. 61/495,579, filed Jun. 10, 2011, entitled 1-WIRE BUS WHICH IS DROP-IN COMPATIBLE WITH I2C TRANSMISSIONS, the specification of which is incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
61495579 | Jun 2011 | US | |
61616723 | Mar 2012 | US |