Author Topic: [SOLVED] Strange i2c problem with pca9544a/atmega328  (Read 3189 times)

0 Members and 1 Guest are viewing this topic.

Offline robseTopic starter

  • Contributor
  • Posts: 23
  • Country: it
[SOLVED] Strange i2c problem with pca9544a/atmega328
« on: December 04, 2018, 06:55:52 pm »
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 enlarge


Explaination: There is one ATmega328P, one INA219 i2c current meter and one PCA9544 i2c multiplexer. As you see I have 100nf capacitors near the ICs
The 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 bus
So this means that even simple i2c commands don't work after a short time

This 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 PCA9544A
  if (channel == 0xFF){Wire.write(0x00);} //deselect all channels
  else {Wire.write(controlRegister);}     //set to selected channel
  Wire.endTransmission();


I attached everything to my Rigol. Yellow channel SDA, Blue channel SCL


Image 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 INA219


Now to the issues:


Image 4. A rare event when the PCA9544 works for sometime, then it starts sending 0xFF
The SCL on the right part is also narrower, and SDA doesn't reach near 0 volts .. Why ?  |O




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 2V


Image 6. Always the same code. Here SCL was up, while SDA was left at about 1V 



Image 7. Is that noise or what on SCL ? 


Can someone shed some light on this ?  :scared:

Feel free to ask for any other detail

Thank you,
Robse
« Last Edit: December 06, 2018, 12:58:38 pm by robse »
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: Strange i2c problem with pca9544a/atmega328
« Reply #1 on: December 04, 2018, 08:28:36 pm »
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 work

if 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.
 

Offline robseTopic starter

  • Contributor
  • Posts: 23
  • Country: it
Re: Strange i2c problem with pca9544a/atmega328
« Reply #2 on: December 04, 2018, 08:46:54 pm »
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 arduino

Headers can be ignored, they are used to attach the external components to the PCA9544.

That's it
« Last Edit: December 04, 2018, 08:50:03 pm by robse »
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: Strange i2c problem with pca9544a/atmega328
« Reply #3 on: December 04, 2018, 09:04:08 pm »
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
 

Offline robseTopic starter

  • Contributor
  • Posts: 23
  • Country: it
Re: Strange i2c problem with pca9544a/atmega328
« Reply #4 on: December 04, 2018, 09:12:46 pm »
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

Yes 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)
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: Strange i2c problem with pca9544a/atmega328
« Reply #5 on: December 04, 2018, 09:27:14 pm »
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
 

Offline robseTopic starter

  • Contributor
  • Posts: 23
  • Country: it
Re: Strange i2c problem with pca9544a/atmega328
« Reply #6 on: December 04, 2018, 09:27:56 pm »
This is the board, wires attached for the oscilloscope





I miss a ground plane, could it be the culprit ?
 

Offline robseTopic starter

  • Contributor
  • Posts: 23
  • Country: it
Re: Strange i2c problem with pca9544a/atmega328
« Reply #7 on: December 04, 2018, 09:32:18 pm »
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

If with replacing the expander you mean taking another brand-new pca9544a I can say I already did it

If 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 ?  ;D
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: Strange i2c problem with pca9544a/atmega328
« Reply #8 on: December 04, 2018, 09:43:01 pm »
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 plane

Well, I don't have much more ideas; maybe someone else has a hint
 

Offline DaJMasta

  • Super Contributor
  • ***
  • Posts: 2298
  • Country: us
    • medpants.com
Re: Strange i2c problem with pca9544a/atmega328
« Reply #9 on: December 04, 2018, 10:05:27 pm »
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?
 

Offline robseTopic starter

  • Contributor
  • Posts: 23
  • Country: it
Re: Strange i2c problem with pca9544a/atmega328
« Reply #10 on: December 06, 2018, 12:57:59 pm »
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 fine

It's not the first time I have this problem, but usually I use white spirit and it suffice

Thanks everyone
 
The following users thanked this post: cdev

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: [SOLVED] Strange i2c problem with pca9544a/atmega328
« Reply #11 on: December 06, 2018, 01:02:02 pm »
thanks for the report; you're not the first one with such an issue - and not the last
 

Offline cdev

  • Super Contributor
  • ***
  • !
  • Posts: 7350
  • Country: 00
Re: [SOLVED] Strange i2c problem with pca9544a/atmega328
« Reply #12 on: December 07, 2018, 01:04:43 am »
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!
"What the large print giveth, the small print taketh away."
 

Offline robseTopic starter

  • Contributor
  • Posts: 23
  • Country: it
Re: [SOLVED] Strange i2c problem with pca9544a/atmega328
« Reply #13 on: December 08, 2018, 05:57:10 pm »
Could you upload your images to the blog rather than hosting them on imgur?

Do you mean to modify this post or for the future ?

Using the forum attachments, how you can place images in between paragraphs ?

Regards,
Robse
 

Offline cdev

  • Super Contributor
  • ***
  • !
  • Posts: 7350
  • Country: 00
Re: [SOLVED] Strange i2c problem with pca9544a/atmega328
« Reply #14 on: January 19, 2019, 12:25:04 am »
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.
"What the large print giveth, the small print taketh away."
 
The following users thanked this post: robse


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf