Troubleshooting guide.
Right. So you have built your first system using the I²C bus and you find out that it doesn't work as it should. This section covers a few of the common pitfalls involved in using the bus. First thing to check is : Are the pull-up resistors connected. Probably the most common error is that people forget to connect a pull-up resistor between SDA and VCC and SCL and VCC. Remember : SDA and SCL are open collector or open-drain lines. Resistance value should be between 4K7 and 47K. The longer you make your lines the lower the resistance value should be. This is to force more current into the lines to overcome the capacitance formed by the lines. (This is very important if you want to run on high speeds) Check that the lines can be toggled between the logic levels. Check that the levels on both SDA and SCL fall into the allowed range. Check this both for high and low levels. By now you should have a bus that is capable of transporting I²C signals. Now you can try to send some information to a chip or read some information It is best to connect only one slave device to the I²C bus. The chip is not responding. Check following things in order Are SCL and SDA connected correctly ? Are you accessing the right address ? Has the start command been issued correctly ?. If you have a storage scope you can monitor the bus by connecting Channel 1 to SDA and channel 2 to SCL. Set the scope on Single shot trigger on channel 2. Set pre-trigger to 1 division. If you don't have a scope you can use another trick. Send the start command plus the slave address .Now make the SCL line high . Your Master is now waiting for ACK from the slave device. You can connect a led + resistor between VCC and SDA. If the led does not light then something is wrong. ___ VCC ---|>|--|___|--- SDA LED 470 Ohms Send a couple of stop commands and then try again.It is possible that the chip is locking up due to power-on effects. Replace the chip. It could be defective. Now you can connect the other devices one by one. Each time try to access them. I get strange results. Reading a device a couple of times ends up with different data all the time. Writing does not give predictable results. Sometimes the bus even locks up. The most logic explanation here is that you have 2 chips on the same address. This can happen. Example : You have a circuit that uses 2 PCF8574 I/O ports. In your hurry you forget to wire them for different addresses. (You can have up to 8 of these in your circuit) That's about it. In most other cases you will need a storage scope to view what is actually happening on the I²C bus.
I disclaim everything. The contents of this article might be totally inaccurate, inappropriate, misguided, or otherwise perverse - except for my name (hopefully I got that right). Copyright (c) 1995 by Vincent Himpe, all rights reserved. This FAQ may be posted to any USENET newsgroup, on-line service, or BBS as long as it is posted in its entirety and includes this copyright statement. You are allowed to extract portions of this FAQ to send by e-mail provided that mention the following information: '' Extracted from The I²CFaq (c) Vincent Himpe. Posted in SCI.ELECTRONICS '' This FAQ ,or portions of it, may not be distributed for financial gain. This FAQ ,or portions of it ,may not be included in commercial collections or compilations without express permission from the author. ----------------------------------- Vincent Himpe - vincent.himpe@ping.be
Back to the topPrevious
chapter
Index