Etiquetas

jueves, 17 de septiembre de 2015

I2C communication protocol

I2C communication protocol


I2C is a serial communications bus. Its name comes from Inter-Integrated Circuit (Inter-Integrated Circuit)

The Philips Design in 1992. It is a bus widely used in industry, mainly to communicate microcontroller and its peripherals in embedded systems and integrated generalizing more to communicate with each other that normally reside in the same PCB circuits. Some of the electronic equipment including integrated circuits with I2C bus are 24Cxx memories, signal processors TVs (LA7610, TA1223, DTC810, ...), video encoders DVD players (SAA 7128, TC 90A32F, ...), preamplifiers video monitors (KB 2502), etc.

Lines using the I2C bus to transmit information are:

• A data to serial data (SDA)

• Another to watch the serial clock signal (SCL)

• Third line is also needed, but this is only the reference (GND). As often communicate circuits in a same plate that share a same mass this third line usually not necessary.

• The first two lines are open drain, so they need pull-up resistors.

• The devices connected to the I2C bus have a unique address for each. They can also be masters or slaves. The master device initiates the transfer of data and also generates the clock signal, but it is not necessary that the teacher is always the same device, this feature can be switched the devices with that capability. The bus allows connection of multiple masters, since it includes a collision detector.


• Transactions on the I2C bus have this format:
| Home | 8 Bits Address | Reading o | Bit annealing | Condition repeated call
| Writing |
| Start | A7 A6 A5 A4 A3 A2 A1 R / W | ACK | ... DATA ... | ACK | stop | idle |




• The time displayed in milliseconds (ms 97 204) is the time it took to get the rating. The bus is free when SDA and SCL are logic high. Also keep in mind that the firmware takes about 3 seconds to boot the first time. Before a data exchange between the master circuit and the Slaves, the Master is established should inform the start of communication (Start condition) SDA line falls to zero while SCL remains high. From this point begins the data transfer

• The following is the S which is the bit of Star. The master starts the communication by sending a pattern called "start condition". This alerts the slave devices, putting them waiting for a transaction.

• Then it appears 90. This is the 7-bit address plus 1 bit dedicated to the function read or write (WRITE / READ). In this last bit will use 0 for writing and one for reading. The address sent is compared by each slave on the bus with its own address, if the two match, the slave addressed is considered a slave-slave-transmitter or receiver depending on the bit R / W.

Consider the 90.

9 out of binary hexadecimal number 1001 consists of the address bits (A7 (1), A6 (0), A5 (0) and A4 (1)) which are the standard DS 1621 is assigned the chip.

0 hexadecimal leaves the binary number 0000 comprises 3 bits of address and a fourth bit indicates whether you are writing or reading (A3 (0), A2 (0), A1 (0) and WRITE (0)) in this case the teacher is writing to the slave. If reading, as is later the teacher read and change the number to 0001 and the resulting number will be 91.


The A3, A2 and A1 bits are both 0 because they are connected to GND as shown in the image, if one were to be Vcc.



• The address sent is compared by each slave on the bus with its own address, if the two match, the slave addressed is considered a slave-slave-transmitter or receiver depending on the bit R / W.

• In the state free bus, any device can take the I2C bus as a teacher.

•.After 90 appears A. The slave responds by sending an ACK bit that tells the master device that the slave acknowledges the request and is able to communicate.

• Following the exchange of information between devices begins.

• The master sends the address of the internal register of the device you want to read or write. In the case of the previous image is AA, which is binary 10101010. Data byte 1: This is the first data byte itself as above we can not choose us and is imposed by the protocol. Here we can put the data we want in case of communication with remote sensing is to use a common registration number we want to write or read.

This step as many times as necessary repeats.

• The slave responds with another ACK bit.

• Now the teacher can begin to read or write data bytes. All data bytes must consist of 8 bits, the maximum number of bytes that can be sent in a transmission is not restricted, being the slave who determines this amount according to their characteristics.

• Each byte read / written by the teacher must necessarily be recognized by an ACK bit by the master / slave device.

• Repeat the previous 2 steps to end the communication between master and slave.

• Even if the teacher always monitors the status of the clock line, a slave of low speed or be stopped transferring data while performing another function, you can force the SCL line low. This makes the master into a wait state, during which transmits information not waiting for the slave is ready to continue the transfer at the point where it had been stopped.

• When communication is complete, the master will transmit a "stop condition" to free the bus (p letter at the end)

• After the "stop condition", it is mandatory for the bus to be idle (unemployed) for a few microseconds.




Image of the practice in Proteus



Image of the bus I2C



Image of the Real Time Clock



Image of the LCD




Image of the source code In Proteus



No hay comentarios:

Publicar un comentario