I2C Read/Write problems


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JD123 View Post
    If the device address is $10 then doesn't the address have to be left shifted one place?
    I thought PBP handled that part for you. 'cause with a generic serial eeprom, the address is something like $a0, and that's how you address it...$a0, without the left shift, PBP handles the R/W bit.
    But then again, we don't know exactly what kind of secret magic device is being addressed here...

  2. #2
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    I thought PBP handled that part for you. 'cause with a generic serial eeprom, the address is something like $a0, and that's how you address it...$a0, without the left shift, PBP handles the R/W bit.
    But then again, we don't know exactly what kind of secret magic device is being addressed here...
    $A0 is the LOWER 7 bit's of the address, shifted left one place. The DEVICE address being sent out and 'seen' by the reciever is %01010000, or $50. Check the specs of I2C, not just EEPROMS. The device address is specified as a 7 bit address, not 8. But since we are adding the R/W bit to the 8 bit address byte, we have to left shift the DEVICE address one place.

    The confusion comes in dealing with 2 different data "specs" or "types" combined into one 8 bit Byte being send. Then suming the two values to "use" one value. That "one" value is not the device address.

    You ever do this: (I know I have)
    Gang 8 64KBit EEproms and use the device address (bit 4:1) by just rolling the long address over directly into the device address. It won't work. Trust me, just shift the address left once to embed the address into the device address byte.
    Last edited by JD123; - 2nd April 2008 at 21:52.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JD123 View Post
    The DEVICE address being sent out and 'seen' by the reciever is %01010000, or $50. Check the specs of I2C, not just EEPROMS. The device address is specified as a 7 bit address, not 8. But since we are adding the R/W bit to the 8 bit address byte, we have to left shift the DEVICE address one place........
    I guess that's what I'm saying here...is that PBP handles it for us.

    The confusion comes in dealing with 2 different data "specs" or "types" combined into one 8 bit Byte being send.
    Confusion say...Man who live in glass house...should dress in basement...

  4. #4
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Confusion say...Man who live in glass house...should dress in basement...
    My spell checker wants another quarter and I'm too cheap to give it up!
    Last edited by JD123; - 2nd April 2008 at 22:04.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  5. #5
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    I guess that's what I'm saying here...is that PBP handles it for us.
    No. it doesn't. PBP handles the R/W bit for us. We still have to give it the correct address, formated to the device address byte. That's why you send %10100000 and the reciever "sees" %01010000 as the device address.

    Now, if the receiving device specs say "send $xyz" then they have already formated the address for you. That still doesn't change the fact that the address is the upper 7 bits shifted right one place.
    Last edited by JD123; - 2nd April 2008 at 22:07.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JD123 View Post
    No. it doesn't. PBP handles the R/W bit for us. We still have to give it the correct address, formated to the device address byte. That's why you send %10100000 and the reciever "sees" %01010000 as the device address.
    Ok, I'm smelling what your cooking... I'm pickin' up what you're layin' down...
    (what happens if we overclock that same PIC to 50Ghz to get really fast I2C? )

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Wow... lots of help... I'm attempting to get the read to work, using $20 for the control byte. I'll see what I can do... eventually I want to be able to read and write registers using the LCD screen as sort of a 'menu' guide, and using my last to ports as button inputs.

    EDIT:

    Can anyone give me an idea as to why the clock is so far off? The book says 400KHz devices are accessible if the clock is above 8MHz (I'm using 20), but my clock is at 122Khz. The manufacturer of the board said this wasn't a problem so long as the PIC supported 'clock stretching'.

    If anyone is interested, what I'm trying to connect to is an 'Open Servo' board.
    Last edited by Dispersion123; - 3rd April 2008 at 06:20.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dispersion123 View Post
    Can anyone give me an idea as to why the clock is so far off? The book says 400KHz devices are accessible if the clock is above 8MHz (I'm using 20), but my clock is at 122Khz. The manufacturer of the board said this wasn't a problem so long as the PIC supported 'clock stretching'.
    See Post #2...
    400Khz is the MAXIMUM for most fast I2C devices. It's not neccessarily the speed that the PIC is communicating to said I2C device. I2CRead/I2CWrite are software, 'bit-banged' commands, not hardware.
    If you ran your PIC clock at 40Mhz vs. 20Mhz, the I2C clock may very well jump up to 244Khz.

  9. #9
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dispersion123 View Post
    Wow... lots of help... I'm attempting to get the read to work, using $20 for the control byte. I'll see what I can do...
    Here's the $24 million dollar question:

    Does the documents for the slave IC say send address $10 or does it say that its address is $10.

    So far as the clocking speed, there can be pulses that come close to 400k being send out, but that's just for a short period of time. The clocking speed will most likely vary in speed depending on what's being done. BTW, how are you reading the clocking speed? O-scope or frequency counter?
    Last edited by JD123; - 3rd April 2008 at 16:28.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  10. #10
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Ok, I'm smelling what your cooking... I'm pickin' up what you're layin' down...
    (what happens if we overclock that same PIC to 50Ghz to get really fast I2C? )
    50Ghz? Don't know, but I think you can use the IC as a hot-plate to keep your coffee warm.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  4. I2C slave
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th March 2008, 03:46
  5. Please help with i2cslave i2c slave
    By cycle_girl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st December 2005, 13:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts