Both sides previous revisionPrevious revisionNext revision | Previous revision |
en:iot-open:embeddedcommunicationprotocols2:twi [2023/11/21 20:37] – pczekalski | en:iot-open:embeddedcommunicationprotocols2:twi [2024/05/27 11:11] (current) – ktokarz |
---|
====== TWI (I2C) ====== | ====== TWI (I2C) ====== |
| {{:en:iot-open:czapka_b.png?50| General audience classification icon }}{{:en:iot-open:czapka_e.png?50| General audience classification icon }}\\ |
TWI (Two Wire Interface) is one of embedded systems' most popular communication links and protocols. Philips has designed it as an I2C (Inter-Integrated Circuit) for audio-video appliances controlled by the microprocessor. Many chips can be connected to the processor with this interface, including: | TWI (Two Wire Interface) is one of embedded systems' most popular communication links and protocols. Philips has designed it as an I2C (Inter-Integrated Circuit) for audio-video appliances controlled by the microprocessor. Many chips can be connected to the processor with this interface, including: |
* EEPROM memory chips, | * EEPROM memory chips, |
* displays, | * displays, |
* specialised AV circuits. | * specialised AV circuits. |
TWI, as the name says, uses two wires for communication. One is the data line (SDA); the second is the clock line (SCL). Both lines are common to all circuits connected to the one TWI bus. The method of communication of TWI is the master-slave synchronous serial transmission. It means that data is sent bit after bit synchronised with the clock signal. The SCL line is always controlled by the master unit (usually the microcontroller); the signal on the SDA line is generated by the master or one of the slaves – depending on the direction of communication. Sample connection is present in figure {{ref>RefTWIPic1}}). The frequency rate of the transmission is up to 100 kHz for most of the chips; for some, it can be higher – up to 400 kHz. The new implementation allows an even higher frequency rate, reaching 5 MHz. | TWI, as the name says, uses two wires for communication. One is the data line (SDA); the second is the clock line (SCL). Both lines are common to all circuits connected to the one TWI bus. The method of communication of TWI is the master-slave synchronous serial transmission. It means that data is sent bit after bit synchronised with the clock signal. The SCL line is always controlled by the master unit (usually the microcontroller); the signal on the SDA line is generated by the master or one of the slaves – depending on the direction of communication. Sample connection is present in figure {{ref>RefTWIPic1}}. The frequency rate of the transmission is up to 100 kHz for most of the chips; for some, it can be higher – up to 400 kHz. The new implementation allows an even higher frequency rate, reaching 5 MHz. |
At the output side of units, the lines have the open-collector or open-drain circuit. This means that external pullup resistors are needed to ensure the proper operation of the TWI bus. The value of these resistors depends on the number of connected elements, the speed of transmission, and the power supply voltage. It can be calculated with the formulas presented, e.g. in the Texas Instrument Application Report ((Rajan Arora, I2C Bus Pullup Resistor Calculation, Texas Instruments Application Report)). Usually, it is assumed between 1 kΩ and 4.7 kΩ. | At the output side of units, the lines have the open-collector or open-drain circuit. This means that external pullup resistors are needed to ensure the proper operation of the TWI bus. The value of these resistors depends on the number of connected elements, the speed of transmission, and the power supply voltage. It can be calculated with the formulas presented, e.g. in the Texas Instrument Application Report ((Rajan Arora, I2C Bus Pullup Resistor Calculation, Texas Instruments Application Report)). Usually, it is assumed between 1 kΩ and 4.7 kΩ. |
| |
<figure RefTWIPic1> | <figure RefTWIPic1> |
{{ :en:iot-open:embeddedcommunicationprotocols2:twi_diagram.png?nolink&500 | Sample TWI bus connection}} | {{ :en:iot-open:embeddedcommunicationprotocols2:twi_diagram.png?500 | Sample TWI bus connection}} |
<caption>Sample TWI connection</caption> | <caption>Sample TWI connection</caption> |
</figure> | </figure> |
| |
<figure RefTWIPic3> | <figure RefTWIPic3> |
{{ :en:iot-open:embeddedcommunicationprotocols2:twi_timing.png?nolink&600 | TWI frame}} | {{ :en:iot-open:embeddedcommunicationprotocols2:twi_timing.png?600 | TWI frame}} |
<caption>TWI frame</caption> | <caption>TWI frame</caption> |
</figure> | </figure> |