This counts as a NAK (negative acknowledgement). If there is no slave connected and powered on, or it does not have the required address, then it will ignore the address, leaving the SDA line high (by the pull-up resistor). The master then waits for the slave to pull the SDA line low which is an ACK (acknowledge) that a slave of that address exists and is ready to receive data.0 means write (master to slave) and 1 means read (slave to master). Then the read/write bit is transmitted.The logic analyser reports the address as being 0x54 but that is really 0x2A (this is, 42) shifted left one bit, so that the "write" bit (0) is in the least-significant bit place. The 7-bit address of the required slave is then transmitted, most significant bit first.This is when SDA (serial data) is pulled low while SCL (serial clock) stays high. The transmission starts with the "Start condition" (labelled Start).It shows the character "S" (0x53) being sent from the Arduino to the device at address 42.įrom the above graphic note the following points of interest: Let's start with an image - this is a screenshot taken with a logic analyser. Note also that the Atmega specifies a maximum bus capacitance of 400 pf, so that would rule out long cable runs. In other words, you don't swap pins (like you do with serial communications, where you connect Tx to Rx and vice-versa). This is because the pull-up resistors keep the lines high until one of the devices wants to use it by pulling a line low. The pins should be connected together (that is, pin 4 to pin 4, and pin 5 to pin 5, if you are connecting Arduino Unos together). Of course, you also need to connect the GND (ground) pins to complete the circuit. Warning: for multiple I2C devices, or longer cable runs, the 4.7K pull-up resistor (for each line) is recommended.Īlso see further down in this thread for some screen-shots of the effect of using different pull-up resistors. The Atmega328 is configured to use internal pull-up resistors which may be adequate for short cable runs. ![]() These pins may require pull-up resistors (that is, connect them to +5v via something like a 4.7K resistor each). They are also connected to D2 (SDA) and D3 (SCL). On the Arduino Leonardo, the SDA and SCL pins are separate pins, so marked, on the board (next to AREF). On the Arduino Mega, SDA is digital pin 20 and SCL is digital pin 21 (they are marked SDA and SCL on the board itself).
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |