Shop OBEX P1 Docs P2 Docs Learn Events
I2C Troubles!! — Parallax Forums

I2C Troubles!!

jokerswildjokerswild Posts: 31
edited 2006-06-04 07:53 in BASIC Stamp
Hi!

I'm having weird problems with my BS2px24 when i use I2C.
I don't get any SDA or SCL output when both are connected to the device i'm controlling with 4.7k pull-up resistors in place. If i remove the SCL line i can get SDA output but i can't get SCL with SDA disconnected. If i only have the BS2 and pull-up resistors in circuit i get the same problem.

Both pin 1 and 9 work normally with other operations.

i need help!!!

BTW i use the basic schematic in the PBASIC 2.2 docs for the I2C connections.

Comments

  • NewzedNewzed Posts: 2,503
    edited 2006-05-29 23:39
    For I2C I think you have to use pins 0 and 1 or 8 and 9.· No other pins will work.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Do you have a Stamp Tester yet?
    http://hometown.aol.com/newzed/index.html

    ·
  • jokerswildjokerswild Posts: 31
    edited 2006-05-29 23:53
    It doesn't matter if i use pin 0 and 1 or 8 and 9 for SDA and SCL i get the same problem.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-05-30 01:04
    · Sorry, jokerswild, I don't know what your skill-set is, so I'm submitting the attached (re-composed) drawing for clarity; more than once I've assisted others who, it turned out, weren't clear on the jog and join-dot convention/s.
    · If your set-up is solid, then please post your program.
    366 x 188 - 11K
  • jokerswildjokerswild Posts: 31
    edited 2006-05-30 01:41
    Thanks PJ Allen.
    I've got the wiring correct for I2C. I use pin 0 for SDA and pin 1 for SCL.

    This is the basic code i'm using. I'm not 100% sure of the slaveid but i can't get any output from the BS2 with both SDA and SCL connected correctly.

    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    ' I2COUT Pin, SlaveID, { Address { \LowAddress }, } [noparse][[/noparse] OutputData ]
     
    SDA PIN 0 ' I2C SDA pin
    SCL PIN SDA + 1
     
    LCDid   CON $78 'slaveid
    LCDinit CON $40 'init LCD
    LCDwrt  CON $60 'write LCD (starting from pos 0)
     
    PAUSE 250
    I2COUT SDA, LCDid, LCDinit,[noparse][[/noparse]0]       'start LCD, set all segs on
    PAUSE 250
    I2COUT SDA, LCDid, LCDwrt,[noparse][[/noparse]$27, $1F, $05, $07] 'write basic character to LCD
    PAUSE 250
    END
    

    If i run the program with SCL disconnected and then connect while SDA is outputting, the program stops.

    I've even tried just a I2COUT command with all the values written without constants or variables, ie
    ···· I2COUT 0, $78, $40, [noparse][[/noparse]0]
    and still no luck.

    The graphics LCD i'm using is based on the PCF8558 controller.

    help!
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-05-30 01:55
    You have --
    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    ' I2COUT Pin, SlaveID, { Address { \LowAddress }, } [noparse][[/noparse] OutputData ]
     
    [color=red]SDA PIN 0 ' I2C SDA pin
    SCL PIN SDA + 1[/color]
     
    LCDid   CON $78 'slaveid
    LCDinit CON $40 'init LCD
    LCDwrt  CON $60 'write LCD (starting from pos 0)
     
    PAUSE 250
    I2COUT [color=red]SDA[/color], LCDid, LCDinit,[noparse][[/noparse]0]       'start LCD, set all segs on
    PAUSE 250
    I2COUT [color=red]SDA[/color], LCDid, LCDwrt,[noparse][[/noparse]$27, $1F, $05, $07] 'write basic character to LCD
    PAUSE 250
    END
    
    


    Try --
    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    ' I2COUT Pin, SlaveID, { Address { \LowAddress }, } [noparse][[/noparse] OutputData ]
     
    Ipin CON 0      'I2C [i]Pin[/i] choice 
     
    LCDid   CON $78 'slaveid
    LCDinit CON $40 'init LCD
    LCDwrt  CON $60 'write LCD (starting from pos 0)
     
    PAUSE 250
    I2COUT Ipin, LCDid, LCDinit,[noparse][[/noparse]0]       'start LCD, set all segs on
    PAUSE 250
    I2COUT Ipin, LCDid, LCDwrt,[noparse][[/noparse]$27, $1F, $05, $07] 'write basic character to LCD
    PAUSE 250
    END
    
    


    With:
    SDA PIN 0 ' I2C SDA pin
    SCL PIN SDA + 1

    I guess you're trying to declare the I2C pins or something, but that's not necessary, it's a function of the I2CIN/OUT Pin statement's being 0 or 1 (it's all taken care of for you.)
  • jokerswildjokerswild Posts: 31
    edited 2006-05-30 02:32
    Thanks for the quick response PJ Allen.
    I've already tried using different expressions for the PIN field in the I2COUT command without any success.
    Like i mentioned before i've also tried I2COUT 0, $78, $40, [noparse][[/noparse]0] without any variables, pin identifiers or constants also without success.

    It's beginning to seem like there is a problem with the BS2 itself. I can use pins 0, 1, 8 and 9 for other operations like high, low, freqout, pwm etc all without fault, only seems with I2COUT i have problems.

    Are there any related functions to I2COUT other that I2CIN i can use to determine if my BS2 is functioning properly?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-05-30 02:50
    Is there a link for your I2C graphic LCD?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-05-30 02:52
    jokerswild -

    Earlier you said you had a BS-2px24 and now you're saying you have a BS-2. If it really IS a BS-2 and not a BS-2p that's your problem. The BS-2 does not support the I2C commands.

    If it is a BS-2p or higher, what specific device are you trying to access?

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • jokerswildjokerswild Posts: 31
    edited 2006-05-30 03:05
    PJ Allen-

    The graphics LCD I'm trying to use is from an Ericsson A1018s mobile phone and is controlled by the Philips PCF8558 universal graphics controller. Here is a link to the Philips datasheet:

    http://www.semiconductors.philips.com/acrobat/datasheets/PCF8558_2.pdf

    With SDA and SCL both connected with 4.7k pull-up resistors to 5V i don't get ANY output. With SCL not connected i get SDA output.

    I should be able to see both SDA and SCL data when using I2COUT without any device connected, just pull-up resistors in place.



    Bruce-

    I am using a BS2px24 IC. My laziness not typing the full name in. sorry!

    Thank you both for your replies!!
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-05-30 03:47
    jokerswild -

    What are you doing with pin SA0 on the PCF8558? I suspect it should be tied directly to Vss, and not left floating.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • jokerswildjokerswild Posts: 31
    edited 2006-05-30 04:28
    Bruce-

    The LCD has the PCF8558 embedded in the screen so i'm not sure if SA0 high or low, thats why i'm not 100% sure if the slaveid is $78 or $7A.

    Perhaps i'm not asking my question correctly.

    If i have the following circuit and run the command

    I2COUT 0, $78, $40, [noparse][[/noparse]$A1, $22, $CC]
    

    I should see the SCL pin 1 pulse clock signal and SDA pin 0 pulse $78, $40 etc ?

    Using my scope i can only see the SDA signal and only when SCL is NOT connected to anything.
    If i run the command with SCL connected as shown in the circuit i get no output from either pin.
    518 x 439 - 7K
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-05-30 05:58
    jokerswild -

    I think I can see where your problem may be. I2C is an entire protocal, which includes communication prefixes and sequences, such as "START", "ACK", "STOP", etc. Depending on the particular period in the protocal sequence, unless you knew exactly what to expect, and both master and slave are active and accessable, and the proper commands have been issued and acknowledged, in the proper order, something as short as the electrical sequence you're seeing may be all that you will see.

    Unlike synchronous serial data transmission (Microwire, SPI, 3-4 wire serial, etc), there aren't simply clock signals traveling across the clock line, and data bits traveling in sequence across the data line. The clock and data lines are used in combination for "signalling" between the master and the slave, and the data line carries prefixes and suffixes beyond the actual raw data.

    I hope that makes some sense to you. Otherwise, it's slogging through the entire Philips I2C Manual to really understand it at the root level. If you do end up doing that - bring lunch! smile.gif

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 5/30/2006 9:09:40 AM GMT
  • kelvin jameskelvin james Posts: 531
    edited 2006-05-30 06:22
    For the address, wouldn't a binary value of 0111100 be $3C in hex, not $78 ?

    kelvin
  • jokerswildjokerswild Posts: 31
    edited 2006-05-30 06:38
    I've got wave forms for the I2C protocol so i thought i would see the same.
    Its just strange that i have no data transmission when i have both SDA and SCL connected but SDA without SCL connected.
    Anyway ive got a DS1337 realtime clock which uses I2C and i have all the info for that so i might try and get that working first.

    I appreciate your comments Bruce and PJ Allen.


    kelvin-

    the slaveid is an 8 bit string, so 01111000 is $78. lsb is the SA0 with allows 2 controllers to be connected to the same line, which makes it 01111001 or 01111000 ($7A or $78).
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-30 14:11
    One thing to consider is that if connecting the SCL line stops the BS2px then perhaps the target device is damaged in some way.· Do you have another I2C device you can test communication with?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-05-30 14:31
    CS (P) -- I think jokerswild is saying that without his device connected at all, and apparently o'scoping, the SDA and SCL pins aren't happening as he expects.
  • kelvin jameskelvin james Posts: 531
    edited 2006-05-31 05:47
    Here is a web site that has some pretty good info. Not the same chip, but looks close to the same specs, may help you out if you have not seen it yet. Check the i2c circuit.

    www.xs4all.nl/~lous/i2c_lcd/lph_i2c.htm

    Post Edited (kelvin james) : 5/31/2006 5:55:00 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-31 15:49
    Without the device connected you should still have the pull-up resistors to properly see the signals.· Do you still have these resistors installed when the device is not connected?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • jokerswildjokerswild Posts: 31
    edited 2006-06-01 00:30
    When i'm testing i have 4.7k resistors pulling to 5V. I can only get SDA waveform on o'scope when SCL is not connected to anything. When i connect SCL to its pull-up resistor i get no waveform from SDA or SCL. With SDA not connected and SCL connected to a pull-up resistor i get no signal from SCL.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-06-01 02:20
    jokerswild -

    One end of each resistor goes to SCL and SDA repectively. Where have you connected the other end of each resistor? What voltages are you reading at that connection, before and after the resistors are connected?

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • jokerswildjokerswild Posts: 31
    edited 2006-06-02 11:33
    The pull-up resistors are connected to positve 5V supplied from a LM7805. The +5V is common with basic stamp Vdd, Data Vdd for the lcd and the two pull-up resistors for SDA and SCL. When i measure the voltage at SDA or SCL i get 5V. When i get a signal from SDA with SCL disconnected its 0V to 4.8V only on SDA. Same result with LCD connected or disconnected.

    I've got a one-wire ADC that works on any of the pins of the BS2px so it seams strange..
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-06-02 12:03
    jokerswild -

    First, are you SURE the LCD from the Ericsson A1018s mobile phone is a 5 volt device? Many, if not most, mobile phone "attached accessories" (today) are 3.3 VDC or lower.

    Second, what is feeding power to the LM7805?

    Third, are you using capacitors on the input and output of the LM7805, as shown in this somewhat generic LM78xxx schematic?:
    http://www.national.com/pf/LM/LM78L05.html

    Do you have an ampacity budget for all of the items you're running off of this LM7805? If not, I'd suggest going through that exercise, since you can only pull 100 mA TOTAL from it, and the BS-2P is going to be pulling 40 mA or 40% of that budget all by itself!

    If it's not apparent from my various questions, my thinking is drifting towards possible sagging or lowered input power/voltage from the +5 VDC source. This has been one of the more interesting and challenging problems of late! Congradulations smile.gif

    BTW - Approximately how old (in months or years) is this BS-2P you're using?

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • petel6petel6 Posts: 4
    edited 2006-06-02 16:44
    I read this thread because I am debugging an I2C situation myself of late. My setup is different, but I also had a problem with the bus not working. I am using another uController which also talks I2C. What I found out thru trial and error was my o'scope was apparently loading down the bus or messing up the ground. I have a Pico model. Anyhow, once I removed it from the bus (I don't remember if I had it on clock or data) it started working. Just a thought.

    pete
  • jokerswildjokerswild Posts: 31
    edited 2006-06-04 07:53
    Well to put an end to my annoying problem I've tried the same code and wiring with a colleagues’ BS2p and it worked first go. Somehow I’ve broken the I2C in my BS2px (?).
    All other functions appear to work correctly.

    Big thanks for the helpful pointers guys.

    Time for an ESD prevention plan I think.
Sign In or Register to comment.