ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites

THE SOFTWARE IMPLEMENTATION OF I2C PROTOCOL


Circuit Cellar Online
THE MAGAZINE FOR COMPUTER APPLICATIONS
Circuit Cellar Online offers articles illustrating creative solutions
and unique applications through complete projects, practical
tutorials, and useful design techniques.

SOFTWARE IMPLEMENTATION OF I2C PROTOCOL

Applications
by Dariusz Caban

Start ý The Bus ý The Protocol ý The Process ý Conclusions ý Sources and PDF

THE PROTOCOL

The I2C protocol is level-sensitive. The data must be stable when SCL is high. Except for two situations, the state of the SDA line can only change when SCL is low. The exceptions have special meanings (see Figure 2). A 1-to-0 transition signals the beginning of a transfer and is termed as a start condition. A 0-to-1 transition signals the end of a transfer and is termed as a stop condition. The data is transferred in bytes, with the most significant bit sent first. Note that the byte transfer requires nine clock pulses. The transfer of a byteýs bits takes eight pulses, and the ninth is used for acknowledgment. Between start and stop conditions, an unrestricted number of bytes can be transferred.

(Click here to enlarge)

Figure 2ýThis diagram shows the issuing of the start and stop conditions and how the byte transfer on the I2C bus is performed.

After a start condition, the byte containing the slave address (or part of the address, when 10-bit addressing is used) and a data direction bit is always sent first (see Figure 3). A start condition can be repeated without first generating a stop condition. This is used to change transfer direction or to address another slave. If there is no acknowledgment from the addressed slave (because it is not connected or performs some internal operation), the master can abort the transfer. Next, if the slave is being written to, it must acknowledge each byte received. Lack of acknowledgment indicates that it cannot accept data. While reading from the slave, the master is also obliged to acknowledge each byte, except the last byte.

(Click here to enlarge)

Figure 3ýThe byte containing all or part of the slave address and the data direction bit are sent first after a start condition.

The master can communicate with the slave according to several scenarios called transfer formats. For example, there are three possible formats when 7-bit addressing is used. Their descriptions can be found in "The I2C-Bus SpecificationýVersion 2.1," by Philips. [1]

PREVIOUS NEXT


Circuit Cellar provides up-to-date information for engineers. Visit www.circuitcellar.com for more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com or subscribe online. ýCircuit Cellar, the Magazine for Computer Applications. Posted with permission.
 
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ