Author Topic: I2C driving me insane :)  (Read 8014 times)

0 Members and 1 Guest are viewing this topic.

Offline lkTopic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: dk
I2C driving me insane :)
« on: July 24, 2012, 10:12:33 am »
Greetings,

I found that the I2C, with the DS1307/I2CEEPROM, i made it work every time in a simulator, but as soon i broke out the hardware, problems seemed to appear, some intermittent others all the time. I have tried two different microcontrollers, pic18f26k22 and pic18f14k22. The hardware i2c on the pic18f26k22, just seemed to pull down the sda/scl lines, at least that is what imagine, as the controller started pulling 100mA more. I decided to try software i2c, again it works in the simulator, but it does not work with real hardware, looking at the attached pictures, the sda/SCL lines just look horrible. I have 4K7 resistors as pull up.

It looks like the SCL/SDA lines are only pulled down 1 volt, i suspect this is what is causing the problem, i just don't know what to do about it, i have been contemplating changing the pull up resistors to 10K.


These links are to the PCB, one partially populated and one empty, i don't know if i have made a screw up with the ground planes.

https://plus.google.com/photos/108987705034973313443/albums/5768671873824080545?authkey=CMPIz_WZwITQqgE&banner=pwa&gpsrc=pwrd1#photos/108987705034973313443/albums/5768671873824080545/5768673308557311586?authkey=CMPIz_WZwITQqgE


My plan with the board is to have a stable platform, that i know is good, so i can start just battling the software errors and not worry too much about hardware :)

Any input is appreciated :)

-lk

 

Offline bsiswoyo

  • Newbie
  • Posts: 7
  • Country: id
    • Bambang Siswoyo
Re: I2C driving me insane :)
« Reply #1 on: July 24, 2012, 10:24:02 am »
Dear.
what simulator you are using ?
Bambang Siswoyo
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: nl
Re: I2C driving me insane :)
« Reply #2 on: July 24, 2012, 10:40:56 am »
@bsiswoyo: I haven't read he is using a simulator.. Seems like some Rigol scope pictures to me.

Usually I2C are all tristate buffers, so open drain output with an input tapped off. This is ofcourse all inside the hardware of the PIC chip, but it means the PIC chip should be able to pull a signal 'low'.

Could it be that your pull-up resistor is too low, or there is another driving source on your I2C nets? What else is connected?
Swapped clock and data?
Verify you send the correct address byte (although, it the clock isn't good, it isn't going to work anyway).
Maybe also make use of the 2ch function of the scope and measure both simultaneously.  :)
 

Offline lkTopic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: dk
Re: I2C driving me insane :)
« Reply #3 on: July 24, 2012, 11:10:46 am »
Hi Bsiswoyo,

im simulating in proteous.

Hans,
Currently i have a 24FC64F eeprom, with addresses set to 0 0 0, so write would be something like 10100000 and read 10100001. And there is a DS1307 RTC on there aswell, but it does not seem to matter if that is there or not.


-lk
 

Offline lkTopic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: dk
Re: I2C driving me insane :)
« Reply #4 on: July 24, 2012, 11:26:07 am »
SDA is channel 1 and scl is channel 2 measured at the pins of the eeprom.

-lk
 

Offline Short Circuit

  • Frequent Contributor
  • **
  • Posts: 439
  • Country: nl
Re: I2C driving me insane :)
« Reply #5 on: July 24, 2012, 12:52:30 pm »
Maybe the pins on your uC are configured as push-pull instead of open-drain...
 

Offline lkTopic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: dk
Re: I2C driving me insane :)
« Reply #6 on: July 24, 2012, 02:50:54 pm »
Hi SC,

For those screendumps i was using software i2c, i have tried using the hardware i2c on another microcontroller but it did not work there either, i have had it working, but not reliably  on another board completely, i don't have any measurements from there however.

I use the software i2c lib in mikroc, looking at this it should handle the direction of the port just fine, if it does not i will have a hard time fixing it :)

// Software I2C connections
sbit Soft_I2C_Scl           at RB6_bit;
sbit Soft_I2C_Sda           at RB4_bit;
sbit Soft_I2C_Scl_Direction at TRISB6_bit;
sbit Soft_I2C_Sda_Direction at TRISB4_bit;

-lk
 

Offline lkTopic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: dk
Re: I2C driving me insane :)
« Reply #7 on: July 24, 2012, 03:05:48 pm »
Little update, i changed the pullups to 10k, but the signal still looks distorted, and still only drops 1 volt, i would expect it to drop to 0.


-lk
 

Offline lkTopic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: dk
Re: I2C driving me insane :)
« Reply #8 on: July 24, 2012, 04:37:10 pm »
I build up a partial setup on a breadboard, with 10k pullups, and now it looks good, so i guess that i have something with my pcb design. Could it be that i have noise between my sda and clk lines on the pcb?

any expert advice is welcome, im just a newbie :)


-lk
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: nl
Re: I2C driving me insane :)
« Reply #9 on: July 24, 2012, 05:02:30 pm »
Isolating the software on a seperate design (breadboard) with similar chips is good. I guess you're programming exactly the same firmware in both devices? Using exactly the same pins etc.?

As I said, is there anything else that is connected to your I2C SDA en SCL pins? Other than the MCU, pullups and devices.
See, if a device wants to keep the SCL pin high, and you pull it low, you're basically 'shorting' out the pin which means it drops to midlevel.
So it means some IC is driving the lines externally. All IC's are also out of reset, right?

Maybe posting a schematic will debug things faster.
 

Offline Frangible

  • Regular Contributor
  • *
  • Posts: 109
  • Country: us
  • Contraptioneer
Re: I2C driving me insane :)
« Reply #10 on: July 24, 2012, 05:34:55 pm »
Double-check how you're setting up the PIC GPIO config for those pins.  Sometimes enabling the alternate functionality of a pin may not automatically turn off its output driver.  For instance, if the pin is set up as a GPIO output, and the secondary I2C functionality is enabled, you may have a conflict between the GPIO totem driving the output high, and the I2C output trying to pull it low.

For grins, set the GPIO function as an input to make sure that driver is turned off.
 

Offline lkTopic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: dk
Re: I2C driving me insane :)
« Reply #11 on: July 24, 2012, 07:11:22 pm »
Hans,
the software was exactly the same, samepins everything. Now i pulled the eeprom from the board, and added it to the breadboard, and i had to modify the software to add uart output, so that i can do some output if the readback from the eeprom matches what i have written to it. that works like a charm.

What I'm wondering is if i have problems on my PCB due to the fact that i have a copper plane pour for the ground plane on both the top and bottom copper, could this be causing capacitance? that causes it to blow up in my face :)

-Lk
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5179
  • Country: nl
Re: I2C driving me insane :)
« Reply #12 on: July 24, 2012, 07:45:36 pm »
It's not capacitance or noise, my guess is that there is something wrong with your PCB.
But because you are only showing one side on the photo's it's hard to say what it is.
Keyboard error: Press F1 to continue.
 

Offline Short Circuit

  • Frequent Contributor
  • **
  • Posts: 439
  • Country: nl
Re: I2C driving me insane :)
« Reply #13 on: July 24, 2012, 08:18:38 pm »
What signals do you get on the PCB without the eeprom installed?
And you may want to take a look at the VCC, good chance that it is dipping similar to the I2C lines, indicating some kind of shortcut.
 

Offline lkTopic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: dk
Re: I2C driving me insane :)
« Reply #14 on: July 25, 2012, 07:08:01 am »
PAOPBZ,
https://picasaweb.google.com/108987705034973313443/I2cproblems?authkey=Gv1sRgCMPIz_WZwITQqgE#
I have added the backside for the PCB.

SC,

I did notice a problem when i ran the board without the eeprom in it, but at that time i was busy building the breadboard, so i did not investigate it further, but i will give the vcc a look when i get a chance this evening. I guess i should poke around after shortsbetween sda/scl and vcc?

-lk
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8545
  • Country: us
    • SiliconValleyGarage
Re: I2C driving me insane :)
« Reply #15 on: July 25, 2012, 02:20:29 pm »
Looks like you have a floating ground island o. That board ... Take an ohmmeter and doublecheck that pin 4 of the eeprom socket is really connected to the ground pin of the pic ...

Eeprom gets power but uses ground from the scl and sda when those are switching low....
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline lkTopic starter

  • Regular Contributor
  • *
  • Posts: 152
  • Country: dk
Re: I2C driving me insane :)
« Reply #16 on: July 25, 2012, 02:23:05 pm »
I think i have found the problem :) And guess what its all my fault :P Seems i made a mistake with the GND/VCC pins, that's where the short comes from, thanks everyone for for the help, luckily this is not the only problem with the board. But at least i think i can get some of my confidence in i2c back

The short was on the other device on the i2c bus, and the pullups are connected there as well, no wonder Ive seen so many problems.

Thanks for all the input.

-lk


 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5179
  • Country: nl
Re: I2C driving me insane :)
« Reply #17 on: July 25, 2012, 02:26:20 pm »
Your DS1307 GND is connected to VCC, that might just do the trick...

(edit: Ah, just a minute too late  :( )
Keyboard error: Press F1 to continue.
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8545
  • Country: us
    • SiliconValleyGarage
Re: I2C driving me insane :)
« Reply #18 on: July 25, 2012, 02:58:21 pm »
ahhh .schematics with hidden power pins... whoever invented that concept should be public stripped of all title and rank , tarred , feathered  and prohbitied of ever touching anything electric or electronical again.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf