Problem with I2C (24c32 eeprom)


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    1. It would only take a line to explain that the Control byte always starts 1010
    Then the line would be wrong. The Control Byte depends on the device you're talking to, different devices from different manufacturers can and do have different Control Codes. Refer to the DATASHEET of the device you're playing with.

    In the examples, the Control byte for the smaller chips is given as %1010xxx0 and x means 'don't care.' It does matter is your chip has a hard wired address. e.g

    A2 to G, A1 to G, A0 to VCC - xxx becomes 001.
    A2 to VCC, A1 to G, A0 to G - xxx becomes 100 etc.
    In the PBP Manual 'xxx' is only given as 'don't care' for the 24LC01B and 24LC02B. It's NOT listed as 'xxx' for any others in the table. If you refer to the DATASHEET of those devices you will discover those Address Lines DON'T WORK. This is NOT the case for other (larger) devices and in those cases 'xxx' correctly isn't listed. The PBP manual is concise and correct in this respect. Once again if you missed it from point 1 above... Refer to the DATASHEET of the device you're playing with. The only thing that should be remembered is that the CONTROL BYTE should be a VARIABLE and NOT a Constant.

    3. Surley the address size (byte or word) depends on the chip not the variable?
    No, the PBP Manual states that you should use a WORD if addressing a device that requires a WORD, and a BYTE for any device that requires a BYTE. If you use a CONSTANT, and that CONSTANT has a value which is less than 256 (ie it fits into a BYTE size), the compiler may allocate you a BYTE as that CONSTANT, which if you then go and use that BYTE in a situation where a WORD is expected, you're going to wreck your day.

    It took me 2.5 days to arrive at my present 'thin' understanding - this seems par for the course with this command.
    Actually, other than stating the Control Byte should be a variable I2CREAD & I2CWRITE is well documented.

    If I still have some of the above wrong - please reply.
    See above

    So, in summary... READ the PBP MANUAL... READ the device DATASHEETS. You're only going to have yourself to blame if you don't follow the rules.

  2. #2
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default I2c

    Melanie,

    Thanks very much for taking the time to reply in full. I gone back over by code, taking care of the CON/VAR business and all is now working well.

    Here in the SW of West Australia it's a sweltering 30 degrees (according to my DS1830/PIC 16F84A) - I'm off for a swim in the dam.

    Regards

    Bill Legge

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 23:31
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 04:17
  3. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 22:07
  4. Another I2C Slave Routine Problem
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 06:50
  5. I2C eeprom and DS1307 @40MHz problem
    By ius01 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 20th July 2007, 08:41

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