The two masters can even generate a few cycles of the clock and data that ‘match’, but eventually one will output a ‘low’ when the other tries for a ‘high’. The ‘low’ wins, so the
14
AN10216-01 I2C Manual
‘loser’ device withdraws and waits until the bus is freed again.
There is no minimum clock speed; in fact any device that has problems to ‘keep up the pace’ is allowed to ‘complain’ by holding the clock line low. Because the device generating the clock is also monitoring the voltage on the SCL bus, it immediately ‘knows’ there is a problem and has to wait until the device releases the SCL line.
For full details of the bus capabilities refer to Philips Semiconductors Specification document ‘The I2C bus specification’ or ‘The I2C bus from theory to practice’ book by Paret and Fenger published by John Wiley & Sons. The I2C specification and other useful application information can be found on Philips Semiconductors web site at http://www.semiconductors.philips.com/i2c/
DesignCon 2003 TecForum I2C Bus Overview 34
I2C Address, 7-bit and 10-bit formats • The 1st byte after START determines the Slave to be addressed • Some exceptions to the rule: – “General Call” address: all devices are addressed : 0000 000 + R/W = 0 – 10-bit slave addressing : 1111 0XX + R/W = X
XX = the 2 MSBs The 8 remaining bits Only one device will acknowledge S A1 1 1 1 1 0 X X R/W X X X X X X X X A2 DATA •10-bit addressing The 7 bits Only one device will acknowledge S A X X X X X X X R/W DATA •7-bit addressing More than one device can acknowledge
“0” = Write
SCL
SDA
“1” = Read
SCL
SDA
Slide 34 Slide 34 shows the I2C address scheme. Any I2C device can be attached to the common I2C bus and they talk with each other, passing information back and forth. Each device has a unique 7-bit or 10-bit I2C address. For 7-bit devices, typically the first four bits are fixed, the next three bits are set by hardware address pins (A0, A1, and A2) that allow the user to modify the I2C address allowing up to eight of the same devices to operate on the I2C bus. These pins are held high to VCC, sometimes through a resistor, or held low to GND.
The last bit of the initial byte indicates if the master is going to send (write) or receive (read) data from the slave. Each transmission sequence must begin with the start condition and end with the stop condition. On the 8th clock pulse, SDA is set ‘high’ if data is going to be read from the other device, or ‘low’ if data is going to be sent (write). During its 9th clock, the
master releases SDA line to accomplish the Acknowledge phase. If the other device is connected to the bus, and has decoded and recognized its ‘address’, it will acknowledge by pulling the SDA line low. The responding chip is called the bus ‘slave’.
DesignCon 2003 TecForum I2C Bus Overview 35
I2C Read and Write Operations (1) • Write to a Slave device
The master is a “MASTER - TRANSMITTER”: –it transmits both Clock and Data during the all communication Each byte is acknowledged by the slave device • Read from a Slave device
Master Slave receivertransmitterS slave address W A data A data A P S slave address W A data A data A P < n data bytes >
The master is a “MASTER TRANSMITTER then MASTER - RECEIVER”: – it transmits Clock all the time – it sends slave address data and then becomes a receiver
S slave address R A data A data A P receiver transmitter
Each byte is acknowledged by the master device (except the last one, just before the STOP condition)
< n data bytes >
Slide 35
Terminology for Bus Transfer • F (FREE) - the bus is free; the data line SDA and the SCL clock are both in the high state. • S (START) or SR (Repeated START) - data transfer begins with a start condition (not a start bit). The level of the SDA data line changes from high to low, while the SCL clock line remains high. When this occurs, the bus is ‘busy’. • C (CHANGE) - while the SCL clock line is low, the data bit to be transferred can be applied to the SDA data line by a transmitter. During this time, SDA may change its state, as along as the SCL line remains low. • D (DATA) - a high or low bit of information on the SDA data line is valid during the high level of the SCL clock line. This level must be maintained stable during the entire time that the clock remains high to avoid misinterpretation as a Start or Stop condition. • P (STOP) - data transfer is terminated by a stop condition, (not a stop bit). This occurs when the level on the SDA data line passes from the low state to the high state, while the SCL clock line remains high. When the data transfer has been terminated, the bus is free once again.
15
AN10216-01 I2C Manual
DesignCon 2003 TecForum I2C Bus Overview 36
I2C Read and Write Operations (2) • Combined Write and Read
• Combined Read and Write
S slave address R A data A data A P < n data bytes > S slave address W A data A data A P Sr slave address W A data A data A P < m data bytes >
Each byte is acknowledged by the master device (except the last one, just before the Re-START condition)
Each byte is acknowledged by the slave device
S slave address W A data A data A P S slave address W A data A data A Sr < n data bytes >
Each byte is acknowledged by the slave device
Sr slave address R A data A data A P < m data bytes >
Each byte is acknowledged by the master device (except the last one, just before the STOP condition)
Slide 38 shows how multiple masters can synchronize their clocks, for example during arbitration. When bus capacitance affects the bus rise or fall times the master will also adjust its timing in a similar way.
“1” = Read “0” = Write
“0” = Write “1” = Read
No acknowledge
1
“0” “1” “0” “1”
DesignCon 2003 TecForum I2C Bus Overview 39
I2C Protocol - Arbitration • Two or more masters may generate a START condition at the same time • Arbitration is done on SDA while SCL is HIGH - Slaves are not involved
Start command
“1”
Master 1 loses arbitration DATA1 ≠SDA
“0”
Slide 36
Slide 36 shows a combined read and write operation.
DesignCon 2003 TecForum I2C Bus Overview 37
Acknowledge; Clock Stretching •Acknowledge Done on the 9th clock pulse and is mandatory Æ Transmitter releases the SDA line Æ Receiver pulls down the SDA line (SCL must be HIGH) Æ Transfer is aborted if no acknowledge
• Clock Stretching - Slave device can hold the CLOCK line LOW when performing other functions - Master can slow down the clock to accommodate slow slaves
Acknowledge
Slide 39
If there are two masters on the same bus, there are arbitration procedures applied if both try to take control of the bus at the same time. When two chips try to start communication at the same time they may even generate a few cycles of the clock and data that ‘match’, but eventually one will output a ‘low’ when the other tries for a ‘high’. The ‘low’ wins, so the ‘loser’ device withdraws and waits until the bus is freed again. Once a master (e.g., microcontroller) has control, no other master can take control until the first master sends a stop condition and places the bus in an idle state. Slide 37
DesignCon 2003 TecForum I2C Bus Overview 40
There are 3 basic ways to drive the I2C bus: 1) With a Microcontroller with on-chip I2C Interface Bit oriented - CPU is interrupted after every bit transmission (Example: 87LPC76x) Byte oriented - CPU can be interrupted after every byte transmission (Example: 87C552) 2) With ANY microcontroller: 'Bit Banging’ The I2C protocol can be emulated bit by bit via any bi-directional open drain port 3) With amicrocontrollerin conjunction with bus controller like the PCF8584 or PCA9564 parallel to I2C bus interface IC
Master
I2C BUS
Slave 4Slave 3Slave 2Slave 1
What do I need to drive the I2C bus?
Slide 37 shows how the Acknowledge phase is done and how slave devices can stretch the clock signal. Most Philips slave devices do not control the clock line.
DesignCon 2003 TecForum I2C Bus Overview 38
I2C Protocol - Clock Synchronization Vdd
CLK 1 CLK 2 SCL
Master 1 Master 2
• LOWperiod determined by the longestclock LOWperiod • HIGH period determined by shortest clock HIGH period
2 3 4
Slide 40 Slide 40 shows there are multiple ways to control I2C slaves.
Slide 38
16
AN10216-01 I2C Manual • The I2C bus is a de facto world standard that is implemented in over 1000 different ICs (Philips has > 400) and licensed to more than 70 companies
DesignCon 2003 TecForum I2C Bus Overview 41
Pull-up Resistor calculation DC Approach -Static Load Worst Case scenario: maximum current load that the output transistor can handle Æ 3 mA . This gives us the minimum pull-up resistor value Vdd min - 0.4 V R = With Vdd = 5V (min 4.5 V), Rmin = 1.3 kΩ 3 mA AC Approach -Dynamic load • maximum value of the rise time: –1µs for Standard-mode (100 kHz) –0.3 µs for Fast-mode (400 kHz) • Dynamic load is defined by: – device output capacitances (number of devices) –trace, wiring V(t) = VDD (1-e -t /RC ) Rising time defined between 30% and 70% Trise = 0.847.RC
DesignCon 2003 TecForum I2C Bus Overview 42
I2C Bus recovery • Typical case is when masters fails when doing a read operation in a slave • SDA line is then non usable anymore because of the “Slave-Transmitter” mode. • Methods to recover the SDA line are: – Reset the slave device (assuming the device has a Reset pin) – Use a bus recovery sequence to leave the “Slave-Transmitter” mode • Bus recovery sequence is done as following: 1 -Send 9 clock pulses on SCL line 2 - Ask the master to keep SDA High until the “Slave-Transmitter” releases the SDA line to perform the ACK operation 3 -Keeping SDA High during the ACK means that the “Master-Receiver” does not acknowledge the previous by
แบบที่สองแม้สามารถสร้างกี่วงจรนาฬิกาและข้อมูลที่ 'ตรง' แต่ในที่สุดหนึ่งจะออกเป็น 'ต่ำ' อื่น ๆ ปัญหาสำหรับ 'สูง' ชนะ 'ต่ำ' เพื่อ 14 AN10216-01 I2C ด้วยตนเอง อุปกรณ์ 'ใคร' ถอนตัว และรอจนกว่ารถจะรอดอีก มีความเร็วสัญญาณนาฬิกาที่ต่ำสุดไม่ ในความเป็นจริงอุปกรณ์ที่มีปัญหา 'ติดตามก้าว' สามารถ 'บ่น' โดยถือเส้นตอกต่ำ เนื่องจากยังมีการตรวจสอบอุปกรณ์สร้างนาฬิกา แรงดันไฟฟ้าบนบัส SCL มันทันที 'รู้' มีปัญหา และต้องรอจนกว่าอุปกรณ์ออกบรรทัด SCL รายละเอียดแบบเต็มความสามารถขนส่งถึงที่ฟิลิปส์อิเล็กทรอนิกส์ข้อมูลจำเพาะเกี่ยวกับเอกสาร 'ข้อมูลจำเพาะรถบัส I2C 'หรือ 'เดอะบัส I2C จากทฤษฎีการฝึก' หนังสือ Paret และเผยแพร่ โดยจอห์น Wiley & Sons Fenger ข้อมูลจำเพาะ I2C และข้อมูลโปรแกรมประยุกต์ที่มีประโยชน์อื่น ๆ สามารถพบได้บนฟิลิปส์อิเล็กทรอนิกส์เว็บไซต์ที่ http://www.semiconductors.philips.com/i2c/ DesignCon 2003 TecForum I2C บัสภาพรวม 34ที่อยู่ I2C, 7 บิต และ 10 บิตรูปแบบไบต์•ที่ 1 หลังจากที่เริ่มต้นกำหนดว่าทาสจะ อยู่•บางข้อยกเว้นของกฎ: – "เรียกทั่วไป" ที่อยู่: อุปกรณ์ทั้งหมดมีอยู่: 0000 000 + R/W = 0 – ทาส 10 บิตที่กำหนด: 1111 0XX + R/W = XXX = 2 MSBs 8 บิตที่เหลือเพียงอุปกรณ์หนึ่งตอบว่า S A1 1 1 1 1 0 X X R/W X X X X X X X X A2 ข้อมูล •10 บิตกำหนดบิต 7 เพียงอุปกรณ์หนึ่งจะยอมรับ S A X X X X X X X R/W ข้อมูลกำหนดอุปกรณ์มากกว่าหนึ่งบิต •7 สามารถรับทราบ"0" =เขียนSCLSDA"1" =อ่านSCLSDAภาพนิ่งภาพนิ่ง 34 34 แสดงโครงร่างอยู่ I2C สามารถแนบอุปกรณ์ I2C บัส I2C ทั่วไป และพวกเขาพูดคุยกัน ส่งข้อมูลกลับมา อุปกรณ์แต่ละไม่ซ้ำกัน 7 บิต หรือ บิต 10 I2C อยู่ได้ สำหรับอุปกรณ์ 7 บิต โดยทั่วไปคงที่สี่บิตแรก บิตสามถัดไปจะกำหนด โดยฮาร์ดแวร์ที่อยู่หมุด (A0, A1 และ A2) ที่อนุญาตให้ผู้ใช้สามารถปรับเปลี่ยนอยู่ I2C ให้ถึง 8 อุปกรณ์เดียวกันในการทำงานบนบัส I2C หมุดเหล่านี้จะขึ้นสูงถึง VCC บางครั้งผ่านตัวต้านทาน หรือจัดน้อยไป GND. บิตสุดท้ายของไบต์เริ่มต้นบ่งชี้ว่า ถ้า แบบจะไปส่ง (เขียน) หรือรับข้อมูล (อ่าน) จากการทาส แต่ละลำดับการส่งต้องเริ่มต้น ด้วยเงื่อนไขเริ่มต้น และจบ ด้วยเงื่อนไขการหยุด บนชีพจรนาฬิกา 8, SDA ไว้ 'สูง' ถ้าข้อมูลจะถูกอ่านจากอุปกรณ์อื่น ๆ หรือ 'ต่ำ' ถ้าข้อมูลจะถูกส่ง (เขียน) ระหว่างนาฬิกา 9 การ บรรทัด SDA รุ่นหลักสำเร็จระยะ Acknowledge ถ้าอุปกรณ์อื่นเชื่อมต่อรถ และถอดรหัส และรับรู้ของ 'ที่อยู่' จะยอมรับ โดยดึงบรรทัด SDA ต่ำ ชิตอบสนองเรียกว่าบัส 'ทาส' DesignCon 2003 TecForum I2C บัสภาพรวม 35เขียนทาสกับอุปกรณ์ I2C อ่านและเขียนการดำเนินงาน (1) •หลักคือ "หลัก–ส่ง": -มันส่งนาฬิกาและข้อมูลระหว่างการสื่อสารทั้งหมดเป็นการยอมรับว่า แต่ละไบต์ โดย•อุปกรณ์ทาสอ่านจากอุปกรณ์ทาสReceivertransmitterS หลักทาสทาสท่านให้ข้อมูลที่อยู่ W A ข้อมูล A ข้อมูล A P S ทาสอยู่ W A ข้อมูล A A P <ไบต์ข้อมูล n >หลักจะเป็น "หลักส่งแล้วหลัก–รับ": -มันส่งนาฬิกาตลอดเวลา – ทาสท่านให้ข้อมูลที่อยู่ และจากนั้น กลายเป็นเครื่องรับส่งS ทาสที่อยู่ R A ข้อมูล A ข้อมูล A P รับสัญญาณแต่ละไบต์เป็นยอมรับว่า อุปกรณ์หลัก (ยกเว้นตัวสุดท้าย ก่อนเงื่อนไขหยุด)<ไบต์ข้อมูล n > ภาพนิ่ง 35 คำศัพท์สำหรับการโอนย้ายรถ• F (ฟรี) - รถไม่ รายการข้อมูล SDA และ SCL นาฬิกาได้ทั้งในสถานะสูง • S (เริ่มต้น) หรือ SR (ซ้ำเริ่มต้น) - เริ่มการถ่ายโอนข้อมูลกับเงื่อนไขเริ่มต้น (ไม่บิตเริ่มต้น) ระดับของบรรทัดข้อมูล SDA เปลี่ยนจากสูงต่ำ ขณะที่เส้นตอก SCL ยังคงสูง เมื่อเกิดปัญหานี้ รถบัสไม่ 'ว่าง' • C (เปลี่ยนแปลง) - ในขณะ SCL นาฬิกาบรรทัดต่ำ สามารถใช้บิตข้อมูลที่จะโอนย้ายบรรทัดข้อมูล SDA โดยส่ง ในช่วงเวลานี้ SDA อาจเปลี่ยนสถานะ ก็เป็นบรรทัด SCL ยังคงต่ำ • D (ข้อมูล) - ข้อมูลบรรทัดข้อมูล SDA เล็กสูง หรือต่ำมีผลบังคับใช้ในระดับสูงของเส้นตอก SCL ระดับนี้รักษาเสถียรภาพในช่วงเวลาทั้งที่นาฬิกายังคงสูงเพื่อหลีกเลี่ยงการ misinterpretation เป็นเงื่อนไขเริ่มต้นหรือหยุด การ • P (STOP) - การถ่ายโอนข้อมูลถูกยกเลิก โดยเงื่อนไขการหยุด, (ไม่บิตหยุด) เกิดขึ้นเมื่อระดับบรรทัดข้อมูล SDA ผ่านจากรัฐต่ำการสูง ในขณะที่เส้นตอก SCL ยังคงสูง เมื่อได้ยกเลิกการโอนย้ายข้อมูล รถเมล์ได้ฟรีอีกครั้ง 15 AN10216-01 I2C ด้วยตนเอง DesignCon 2003 TecForum I2C บัสภาพรวม 36I2C อ่าน และเขียนการดำเนินการ (2) •รวมเขียนและอ่าน•รวมอ่านและเขียนข้อมูลที่อยู่ W A ข้อมูล A ข้อมูล A P อาร์ทาสอยู่ W A ข้อมูล A A P < m ข้อมูลไบต์ > ทาสท่าน S ทาสข้อมูลที่อยู่ R A ข้อมูล A A P <ไบต์ข้อมูล n > SEach byte is acknowledged by the master device (except the last one, just before the Re-START condition)Each byte is acknowledged by the slave deviceS slave address W A data A data A P S slave address W A data A data A Sr < n data bytes >Each byte is acknowledged by the slave deviceSr slave address R A data A data A P < m data bytes >Each byte is acknowledged by the master device (except the last one, just before the STOP condition) Slide 38 shows how multiple masters can synchronize their clocks, for example during arbitration. When bus capacitance affects the bus rise or fall times the master will also adjust its timing in a similar way. “1” = Read “0” = Write“0” = Write “1” = ReadNo acknowledge1“0” “1” “0” “1” DesignCon 2003 TecForum I2C Bus Overview 39I2C Protocol - Arbitration • Two or more masters may generate a START condition at the same time • Arbitration is done on SDA while SCL is HIGH - Slaves are not involvedStart command“1” Master 1 loses arbitration DATA1 ≠SDA“0” Slide 36 Slide 36 shows a combined read and write operation. DesignCon 2003 TecForum I2C Bus Overview 37Acknowledge; Clock Stretching •Acknowledge Done on the 9th clock pulse and is mandatory Æ Transmitter releases the SDA line Æ Receiver pulls down the SDA line (SCL must be HIGH) Æ Transfer is aborted if no acknowledge• Clock Stretching - Slave device can hold the CLOCK line LOW when performing other functions - Master can slow down the clock to accommodate slow slavesAcknowledge Slide 39 If there are two masters on the same bus, there are arbitration procedures applied if both try to take control of the bus at the same time. When two chips try to start communication at the same time they may even generate a few cycles of the clock and data that ‘match’, but eventually one will output a ‘low’ when the other tries for a ‘high’. The ‘low’ wins, so the ‘loser’ device withdraws and waits until the bus is freed again. Once a master (e.g., microcontroller) has control, no other master can take control until the first master sends a stop condition and places the bus in an idle state. Slide 37 DesignCon 2003 TecForum I2C Bus Overview 40There are 3 basic ways to drive the I2C bus: 1) With a Microcontroller with on-chip I2C Interface Bit oriented - CPU is interrupted after every bit transmission (Example: 87LPC76x) Byte oriented - CPU can be interrupted after every byte transmission (Example: 87C552) 2) With ANY microcontroller: 'Bit Banging’ The I2C protocol can be emulated bit by bit via any bi-directional open drain port 3) With amicrocontrollerin conjunction with bus controller like the PCF8584 or PCA9564 parallel to I2C bus interface ICMasterI2C BUSSlave 4Slave 3Slave 2Slave 1What do I need to drive the I2C bus?
Slide 37 shows how the Acknowledge phase is done and how slave devices can stretch the clock signal. Most Philips slave devices do not control the clock line.
DesignCon 2003 TecForum I2C Bus Overview 38
I2C Protocol - Clock Synchronization Vdd
CLK 1 CLK 2 SCL
Master 1 Master 2
• LOWperiod determined by the longestclock LOWperiod • HIGH period determined by shortest clock HIGH period
2 3 4
Slide 40 Slide 40 shows there are multiple ways to control I2C slaves.
Slide 38
16
AN10216-01 I2C Manual • The I2C bus is a de facto world standard that is implemented in over 1000 different ICs (Philips has > 400) and licensed to more than 70 companies
DesignCon 2003 TecForum I2C Bus Overview 41
Pull-up Resistor calculation DC Approach -Static Load Worst Case scenario: maximum current load that the output transistor can handle Æ 3 mA . This gives us the minimum pull-up resistor value Vdd min - 0.4 V R = With Vdd = 5V (min 4.5 V), Rmin = 1.3 kΩ 3 mA AC Approach -Dynamic load • maximum value of the rise time: –1µs for Standard-mode (100 kHz) –0.3 µs for Fast-mode (400 kHz) • Dynamic load is defined by: – device output capacitances (number of devices) –trace, wiring V(t) = VDD (1-e -t /RC ) Rising time defined between 30% and 70% Trise = 0.847.RC
DesignCon 2003 TecForum I2C Bus Overview 42
I2C Bus recovery • Typical case is when masters fails when doing a read operation in a slave • SDA line is then non usable anymore because of the “Slave-Transmitter” mode. • Methods to recover the SDA line are: – Reset the slave device (assuming the device has a Reset pin) – Use a bus recovery sequence to leave the “Slave-Transmitter” mode • Bus recovery sequence is done as following: 1 -Send 9 clock pulses on SCL line 2 - Ask the master to keep SDA High until the “Slave-Transmitter” releases the SDA line to perform the ACK operation 3 -Keeping SDA High during the ACK means that the “Master-Receiver” does not acknowledge the previous by
การแปล กรุณารอสักครู่..
