[SOLVED] Strange i2c problem with pca9544a/atmega328 - Page 1
Forum section: electronics / projects

author: robse
author_rank: Contributor
timestamp: December 04, 2018, 06:55:52 pm
content: Hello,I designed the circuit below. An older version with basically the same layout except the FT232RL, worked fine. I soldered two of these defective boards, just to be sure it wasn't a bad component or bad soldering.(Not the best looking schematics, I know)Click to enlargeExplaination: There is one ATmega328P, one INA219 i2c current meter and one PCA9544 i2c multiplexer. As you see I have 100nf capacitors near the ICsThe INA219 and the PCA9544 are on the same i2c bus, with pullup 3.9k resistors that I tried to replace with 2.2k and 10k without much success.As long as I talk to the INA219 (both i2c reads and writes, address 0x45), it works fine. When I start writing to the PCA (address 0x77) it hangs.With hangs I mean that the ATmega stops writing to the serial line too. But sometimes it works correctly for some seconds.This behaviour can be replicated also with a simple i2c scanner.. after a while the 0x77 (the PCA) disappears from the busSo this means that even simple i2c commands don't work after a short timeThis simple code (I use arduino environment) is sufficient to always replicate the problem. The same code works fine on another older board (as stated before)Wire.beginTransmission(0x77); // address of the PCA9544Aif (channel == 0xFF){Wire.write(0x00);} //deselect all channelselse {Wire.write(controlRegister);} //set to selected channelWire.endTransmission();I attached everything to my Rigol. Yellow channel SDA, Blue channel SCLImage 1. Is this waveform ok with 3.9k pullups ?Image 2. Waveform with 2.2k pullups (unfortunatly different horizontal scale than previous image)Image 3. Proper i2c communication with INA219Now to the issues:Image 4. A rare event when the PCA9544 works for sometime, then it starts sending 0xFFThe SCL on the right part is also narrower, and SDA doesn't reach near 0 volts .. Why ?Image 5. Usually all I get from the oscilloscope is this few bits when I turn on the board talking to 0x77. SCL left at 2VImage 6. Always the same code. Here SCL was up, while SDA was left at about 1VImage 7. Is that noise or what on SCL ?Can someone shed some light on this ?Feel free to ask for any other detailThank you,Robse

author: HB9EVI
author_rank: Frequent Contributor
timestamp: December 04, 2018, 08:28:36 pm
content: another example how one should not layout a schematic. if you worked according to this, I'm not so much wondering, why it doesn't workif you know that the code works, you have to find out, what is wrong in your circuit; those waveforms don't look ok, but much more than guessing is imo not possible.

author: robse
author_rank: Contributor
timestamp: December 04, 2018, 08:46:54 pm
content: The schematic is terrible but the connections are right (or at least they are like I wanted them).Basically there are two voltage regulators (on the top), one is 5V and one 3.3v. The latter is not used on this board but used to power an external board (X1 connector on the right).Four ICs:- Atmega328P: I use it just like an arduino- INA219: i2c current meter, you can see the 0.1ohm shunt at top- PCA9544: i2c multiplexer. SC0/SC1 are used to control some external mcp23017 digital multiplexer, SC2 to drive an OLED, SC3 not used. This is the non-working chip even without this things attached- FT232RL: USB-UART that talks to the ATmega328, provides usb serial just like an arduinoHeaders can be ignored, they are used to attach the external components to the PCA9544.That's it

author: HB9EVI
author_rank: Frequent Contributor
timestamp: December 04, 2018, 09:04:08 pm
content: sure, I even know those chips from my own works, but I really have my fight with following the wiring on the schem.And the 3,3V rail is in use; it pulls up SC2/SD2. Did you already try with another expander; that's not easy to say what's going on there, but it's at least very bizarre

author: robse
author_rank: Contributor
timestamp: December 04, 2018, 09:12:46 pm
content: Quote from: HB9EVI on December 04, 2018, 09:04:08 pmYes you are right, the 3.3V is used to pullup SC2/SD2 ... that branch then connects to a 3.3V i2c oled. But again, it just doesn't work without attaching anything.No I didn't try another i2c expander as it just works on my older board !Here I changed the USB chip (ch340g to FT232RL), changed the fuse to a removable one, removed an unused 12v regulator and .. nothing else.Obviously the PCB routing is different, but I did it two times without success (ie I made the boards twice with a different routing)The only doubt I have: does SC3/SD3 needs to be pulled up even if I don't use that line ? I should be able to solder a temporary resistor if needed (everything is smd on the board)

author: HB9EVI
author_rank: Frequent Contributor
timestamp: December 04, 2018, 09:27:14 pm
content: cannot say much about your pcbs, but what the scope tells me, I'd replace the expander if those waveforms are reproduceable and if can exclude a layout/wiring problem

author: robse
author_rank: Contributor
timestamp: December 04, 2018, 09:27:56 pm
content: This is the board, wires attached for the oscilloscopeI miss a ground plane, could it be the culprit ?

author: robse
author_rank: Contributor
timestamp: December 04, 2018, 09:32:18 pm
content: Quote from: HB9EVI on December 04, 2018, 09:27:14 pmIf with replacing the expander you mean taking another brand-new pca9544a I can say I already did itIf you mean instead to use a totally different chip model, that would mean rewriting the schematic, the pcb and the software !Did I already said that I have a working ina219/pca9544a/atmega328 board almost identical ?

author: HB9EVI
author_rank: Frequent Contributor
timestamp: December 04, 2018, 09:43:01 pm
content: I meant a brand new chip of the same type.Even at 400kHz bus speed I'd not expect problems which could be caused by a missing ground planeWell, I don't have much more ideas; maybe someone else has a hint

author: DaJMasta
author_rank: Super Contributor
timestamp: December 04, 2018, 10:05:27 pm
content: Those waveforms definitely look nasty, have you checked the stability of your power rails? Does your source provide enough current to drive all the stuff on the board?Have you checked your solder connections for any missing pads, shorts, or other glitches?

author: robse
author_rank: Contributor
timestamp: December 06, 2018, 12:57:59 pm
content: Solved.At the end it was flux not properly washed in between the pca9544 legs.I cleaned with a brush and isopropyl alcool and now it works fineIt's not the first time I have this problem, but usually I use white spirit and it sufficeThanks everyone

author: HB9EVI
author_rank: Frequent Contributor
timestamp: December 06, 2018, 01:02:02 pm
content: thanks for the report; you're not the first one with such an issue - and not the last

author: cdev
author_rank: Super Contributor
timestamp: December 07, 2018, 01:04:43 am
content: Could you upload your images to the blog rather than hosting them on imgur?It makes posts self-contained. More likely to last.I have had this happen too, BTW.Sorry to ask!

author: robse
author_rank: Contributor
timestamp: December 08, 2018, 05:57:10 pm
content: Quote from: cdev on December 07, 2018, 01:04:43 amDo you mean to modify this post or for the future ?Using the forum attachments, how you can place images in between paragraphs ?Regards,Robse

author: cdev
author_rank: Super Contributor
timestamp: January 19, 2019, 12:25:04 am
content: Once you've uploaded it you can then grab the URL for the eevblog hosted image and insert that as you did the other image - in an edit.