Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:iot-open:embeddedcommunicationprotocols2:twi [2023/06/25 19:07] – created ktokarzen:iot-open:embeddedcommunicationprotocols2:twi [2024/05/27 11:11] (current) ktokarz
Line 1: Line 1:
-==== TWI (I2C) ==== +====== TWI (I2C) ====== 
-TWI (Two Wire Interface) is one of the most popular communication links and protocols used in embedded systemsIt has been designed by Philips as I2C (Inter-Integrated Circuit) for use in audio-video appliances controlled by the microprocessor. There are many chips that can be connected to the processor with this interface, including:+{{: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:
   * EEPROM memory chips,   * EEPROM memory chips,
   * RAM memory chips,   * RAM memory chips,
Line 9: Line 10:
   * 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. 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. The frequency rate of the communication is up to 100 kHz for most of the chipsfor some 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 chipsfor some, it can be higher – up to 400 kHz. The new implementation allows an even higher frequency ratereaching 5 MHz. 
-At the output side of units, the lines have the open-collector or open-drain circuit. It means that there are external pull-up resistors needed to ensure the proper operation of the TWI bus. The value of these resistors depends on the number of connected elements, speed of transmission, and the power supply voltage and can be calculated with the formulas presented e.g. in 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 presentede.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 Ref.Pic.2+<figure RefTWIPic1
-{{ :en:iot-open:embeddedcommunicationprotocols2:twi_diagram.png?nolink&500 | 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>
  
-The data is sent using frames of bytes. Every frame begins with the sequence of signals that is called the start condition. This sequence is detected by slaves and causes them to collect the next eight bits that form the address byte – unique for every circuit on the bus. If one of the slaves recognises its address remains active until the end of the communication frame, others become inactive. To inform the master that some unit has been appropriately addressed slave responses with the acknowledge bit – it generates one bit of low level on the SDA line (the master generates clock pulse). After sending the proper address, data bytes are sent. The direction of the data bytes is controlled by the last bit of the addressfor 0 data is transmitted by the master (Write), and for 1 data is sent by the slave (Read). The receiving unit must acknowledge every full byte (eight bits). There is no limitation on the number of data bytes in the framefor example, samples from the AD converter can be read continuously byte after byte. At the end of the frame, another special sequence is sent by the master – stop condition. It is also possible to generate another start condition without the stop condition. It is called a repeated start condition.+The data is sent using frames of bytes. Every frame begins with sequence of signals called the start condition. Slaves detect this sequence, which causes them to collect the next eight bits that form the address byte – unique for every circuit on the bus. If one of the slaves recognises its address remains active until the end of the communication frame, others become inactive. To inform the master that some unit has been appropriately addressed slave responses with the acknowledge bit – it generates one bit of low level on the SDA line (the master generates clock pulse). After sending the proper address, data bytes are sent. The direction of the data bytes is controlled by the last bit of the addressfor 0data is transmitted by the master (Write), and for 1data is sent by the slave (Read). The receiving unit must acknowledge every full byte (eight bits). There is no limitation on the number of data bytes in the framefor example, samples from the AD converter can be read continuously byte after byte. At the end of the frame, another special sequence is sent by the master–stop condition. It is also possible to generate another start condition without the stop condition. It is called a repeated start condition. Sample TWI fame is present in figure {{ref>RefTWIPic3}}.
  
-<figure Ref.Pic.3+<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>
  
-Address byte activates one chip on the bus only, so every unit must have a unique physical address. This byte usually consists of three elements: a 4-bit field fixed by the producer, a 3-bit field that can be set by connecting three pins of the chip to 0 (ground) or 1 (power supply line), a 1-bit field for setting the direction of communication (R/#W). Some elements (e.g. EEPROM memory chips) use the 3-bit field for internal addressing so there can be only one such circuit connected to one bus. +Address byte only activates one chip on the bus, so every unit must have a unique physical address. This byte usually consists of three elements: a 4-bit field fixed by the producer. This 3-bit field can be set by connecting three pins of the chip to 0 (ground) or 1 (power supply line), a 1-bit field for setting the direction of communication (R/#W). Some elements (e.g. EEPROM memory chips) use the 3-bit field for internal addressingso only one such circuit can be connected to one bus. 
-There are no special rules for the data bytes. The first data byte sent by the master can be used for the configuration of the slave chip. In memory units, it is used for setting the internal address of the memory for writing or readingin multi-channel AD converters to choose the analogue input. Detailed information on the meaning of every bit of the transmission is present in the documentation of the specific integrated circuit. +There are no special rules for the data bytes. The first data byte sent by the master can be used to configure the slave chip. In memory units, it is used for setting the internal address of the memory for writing or reading in multi-channel AD converters to choose the analogue input. Detailed information on the meaning of every bit of the transmission is present in the documentation of the specific integrated circuit. 
-The I2C standard also defines the multi-master mode, but in most of the small projects, there is one master device only.+The I2C standard also defines the multi-master mode, but in most small projects, there is one master device only.
  
en/iot-open/embeddedcommunicationprotocols2/twi.1687720045.txt.gz · Last modified: 2023/06/25 16:07 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0