Shop OBEX P1 Docs P2 Docs Learn Events
I2C not working on P8 — Parallax Forums

I2C not working on P8

ShawnMackShawnMack Posts: 4
edited 2006-01-07 22:29 in BASIC Stamp
I'm stumped but I'm also fairly new at this so I shouldn't be surprised. I’ve hooked up the external EPROM (24LC32A) that came with my kit. I copied the code with LCD and Eprom interface routines in it and fired it up. The LCD displays the data it’s supposed to but the only data that comes back from the Eprom is 255.
·
Not easily deterred I double checked all my jumpers, heeding the warning about pulling up the SDA and SCL, still nothing.
·
I radically shortened the code to write a single known value (83) to address 0 and then retrieve it, still value 255.
·
Eventually I removed my LCD and rewired the I2C to P0 & P1 instead of P8 and P9 viola it works perfectly. Any idea why this would happen? Is there something I needed to do to force 8&9 to be I2C?
·
I’ve tried writing data with 0&1 and reading it with 8&9 and got 255. Interestingly I wrote data with 8&9 then tried reading it with 0&1 and got my test values!
·
Any help or direction would be greatly appreciated, as I’d really like to get my LCD back.

Comments

  • ForrestForrest Posts: 1,341
    edited 2006-01-07 14:50
    How about posting your code and a schematic so we can help you.
  • ShawnMackShawnMack Posts: 4
    edited 2006-01-07 22:08
    Sample code
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
    ' {$PORT COM1}
    ' =========================================================================
    ' -----[noparse][[/noparse] Program Description ]---------------------------------------------
    '
    ' Writes to and reads from I2C EEPROM. Data is displayed in debug.
    '
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
    '
    I2Cpin PIN 0 ' SDA on 8; SCL on 9
    '
    ' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
    '
    MaxEE CON 4095 ' highest EE address
    '
    ' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
    '
    addr VAR Word ' EE address
    addrHi VAR addr.HIGHBYTE
    addrLo VAR addr.LOWBYTE
    tOut VAR Byte ' test value to LCD
    tIn VAR Byte ' test value read from LCD
    ' -----[noparse][[/noparse] Main Code ]-------------------------------------------------------
    '
    Splash:
    DEBUG "Eprom R/W testing"
    Main:
    DEBUG "Loading"
      GOTO ReaditOnly
        tOut = 83
        addr = 0
        ' write value
        I2COUT I2Cpin, $A0, addrHi\addrLo, [noparse][[/noparse]tOut]
        PAUSE 250
        tOut = 83
        addr = 10
        ' write value
        I2COUT I2Cpin, $A0, addrHi\addrLo, [noparse][[/noparse]tOut]
        PAUSE 250
    ReaditOnly:
        addr = 0
        'Get Value
        I2CIN I2Cpin, $A1, addrHi\addrLo, [noparse][[/noparse]tIn]
        ' display results
        DEBUG CR, "0=",DEC tIn
        PAUSE 250
        addr = 10
        'Get Value
        I2CIN I2Cpin, $A1, addrHi\addrLo, [noparse][[/noparse]tIn]
        ' display results
        DEBUG "  10=",DEC tin
        PAUSE 250
    END
    


    Yes I am very careful to change the I2CPin from 0 to 8 as·it is changed on the board.

    The red wires on the attached picture are the wires the project paper describe. These two are not wired att the same time as P0 and P1 but instead of.

    Well I hope there is an attachment...
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-07 22:18
    The structure of the socket connections on the BS2p24/40 demo board cause the BS2p24 P8-P15 connections to be connected to the A8-A15 sockets.· This is noted on pages 2 and 12 of the demo board documentation:

    http://www.parallax.com/dl/docs/prod/boards/BS2p2440DBrd.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ShawnMackShawnMack Posts: 4
    edited 2006-01-07 22:23
    Argh, I was bit by RTFM,·last line on the last page past all the samples shocked.gif

    "Also note that when using a 24-pin module, pins P8 through P15 are accessed via sockets A8 through A15."

    I'll bet most everyone else knows this by second nature. Thanks anyone that took the time to look at this.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-07 22:24
    Yes, one should always Read The Fabulous Manual....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ShawnMackShawnMack Posts: 4
    edited 2006-01-07 22:29
    Too slow to find my own mistake, Jon beat me to it. You were, of course, dead on.

    Humm, it is on page 2. Now I do feel bad.·And a quick vow to never be snide to someone asking a question answered on page 2 of the Freakin' Manual.
Sign In or Register to comment.