I2C driving me insane :) - Page 1
Forum section: electronics / general

author: lk
author_rank: Regular Contributor
timestamp: July 24, 2012, 10:12:33 am
content: 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_WZwITQqgEMy 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 hardwareAny input is appreciated-lk

author: bsiswoyo
author_rank: Newbie
timestamp: July 24, 2012, 10:24:02 am
content: Dear.what simulator you are using ?

author: hans
author_rank: Super Contributor
timestamp: July 24, 2012, 10:40:56 am
content: @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.

author: lk
author_rank: Regular Contributor
timestamp: July 24, 2012, 11:10:46 am
content: 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

author: lk
author_rank: Regular Contributor
timestamp: July 24, 2012, 11:26:07 am
content: SDA is channel 1 and scl is channel 2 measured at the pins of the eeprom.-lk

author: Short Circuit
author_rank: Frequent Contributor
timestamp: July 24, 2012, 12:52:30 pm
content: Maybe the pins on your uC are configured as push-pull instead of open-drain...

author: lk
author_rank: Regular Contributor
timestamp: July 24, 2012, 02:50:54 pm
content: 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 connectionssbit 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

author: lk
author_rank: Regular Contributor
timestamp: July 24, 2012, 03:05:48 pm
content: 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

author: lk
author_rank: Regular Contributor
timestamp: July 24, 2012, 04:37:10 pm
content: 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

author: hans
author_rank: Super Contributor
timestamp: July 24, 2012, 05:02:30 pm
content: 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.

author: Frangible
author_rank: Regular Contributor
timestamp: July 24, 2012, 05:34:55 pm
content: 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.

author: lk
author_rank: Regular Contributor
timestamp: July 24, 2012, 07:11:22 pm
content: 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

author: PA0PBZ
author_rank: Super Contributor
timestamp: July 24, 2012, 07:45:36 pm
content: 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.

author: Short Circuit
author_rank: Frequent Contributor
timestamp: July 24, 2012, 08:18:38 pm
content: 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.

author: lk
author_rank: Regular Contributor
timestamp: July 25, 2012, 07:08:01 am
content: 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

author: free_electron
author_rank: Super Contributor
timestamp: July 25, 2012, 02:20:29 pm
content: 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....

author: lk
author_rank: Regular Contributor
timestamp: July 25, 2012, 02:23:05 pm
content: I think i have found the problemAnd guess what its all my faultSeems 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 backThe 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

author: PA0PBZ
author_rank: Super Contributor
timestamp: July 25, 2012, 02:26:20 pm
content: Your DS1307 GND is connected to VCC, that might just do the trick...(edit: Ah, just a minute too late)

author: free_electron
author_rank: Super Contributor
timestamp: July 25, 2012, 02:58:21 pm
content: 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.