I2CWRITE on a 24LC512


Closed Thread
Results 1 to 18 of 18
  1. #1
    Join Date
    Mar 2007
    Posts
    30

    Post I2CWRITE on a 24LC512

    Hi all,

    i've some problems writing with I2CWRITE to this EEPROM (24LC512), it's wired to the PIC and pulled up via two 4.7k res.

    The pic sometime write, sometime not, this is the code:

    'Dichiaro le variabili
    W0 VAR WORD 'Memorizzazione I2C
    SCL VAR PORTC.3 'Pin per la memoria I2C Clock
    SDA VAR PORTC.4 'Pin per la memoria I2C Data
    I VAR WORD 'Generica
    Control VAR BYTE 'Costante byte di controllo EEPROM

    Control = $A0 'Imposto il byte di controllo

    OPTION_REG = %11101111

    'Imposto la frequenza di oscillazione a 10 Mhz
    DEFINE OSC 10

    'Imposto le porte della PIC
    TRISA = %11111111 'PortA Tutti input
    TRISD = %11111111 'PortD Tutti input
    TRISB = %00000001 'PortB Tutti output a parte 0
    PORTB = %00000000 'PortB Tutti low
    TRISC = %00000000 'PortC Tutti output
    PORTC = %00000000 'PortC Tutti low

    'Inizializzo l'EEPROM
    EEPROMInit:
    W0 = $0
    for I = 0 to $18
    I2cwrite SDA,SCL,CONTROL,I,[W0]
    pause 10
    next

    in the initial state where all the addresses is FFFF, after i use this code i can see this state in the EEPROM:

    0000: 1100 00FF 0000 0000 | ........
    0008: 0000 FF11 0000 FF11 | ........
    0010: FFFF FFFF FFFF FFFF | ........
    0018: FFFF FFFF FFFF FFFF | ........
    0020: FFFF FFFF FFFF FFFF | ........
    0028: FFFF FFFF FFFF FFFF | ........
    0030: FFFF FFFF FFFF FFFF | ........

    Can you help me solving this problem?

    Thank you,

    Luca

    EDIT:
    I'm using a PIC16F877A
    Last edited by oslinux; - 21st March 2007 at 17:49. Reason: Forget to write the PIC i'm using

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Address inputs of the EEPROM ?

    Hi,

    The EEPROM you mentioned has address inputs on pins 1 and 2. Hope you have tried them to ground and not floating.
    BTW this EEPROM supports page write mode. That is you can dump 128 bytes of data to the EEPROM and wait 10mS rather than waiting 10mS for every byte.
    Regards

    Sougata

  3. #3
    Join Date
    Nov 2005
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Perhaps you forget "DEFINE I2C_SLOW 1"
    Ciao

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    oslinux, You don't need the "DEFINE I2C_SLOW 1" statement as the normal speed of this EEPROM is 400Khz.

    Dave Purola,
    N8NTA

  5. #5
    Join Date
    Mar 2007
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    No way, it's always writing the 90% (or less) of what it should...

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    oslinux, Try replacing the 4.7k pullups with 2.2k. Also, what are you doing with A0,A1, and A2 hardware address pins?

    Dave Purola,
    N8NTA

  7. #7
    Join Date
    Mar 2007
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    A0, A1, A2 and WP are grounded, same problem with the 2.2K resistors, only some address are writed.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by oslinux View Post
    A0, A1, A2 and WP are grounded, same problem with the 2.2K resistors, only some address are writed.
    Can you get rid of the 24LC512 and try a 24LC256 instead, or at least a smaller eeprom chip?

    Not that it would make a difference...but it might...ya never know.
    Only reason I mention it is because lots of people have used (are using) the '256, don't think I've heard of anybody using a '512 yet. They are a bit on the new-ish side (2-3 years old I'd guess, maybe...maybe not).

    Also, try writing the whole eeprom, start to finish, try all $00's, try all $ff's, try a few things in between. There will probably be some sort of failure pattern in the eeprom readback itself that we might be able to see from a dump from the chip that'll narrow down the problem.

  9. #9
    Join Date
    Mar 2007
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    Tried with the 256, and it does the same, i mean it does not write everything, anyway i have to use a 512, and when i will get my sample from microchip i will test the 1025, that's because i need more than 256k :S

    Note that the 64 do the same thing...

    Now i've put the whole thing in PROTEUS ISIS and i'v having the same problem, but i can see the log of the eeprom:


    Code:
    212.727201m [RX_CMD     ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0006 RD/WR=Write.
    223.593601m [RX_CMD     ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0007 RD/WR=Write.
    234.460001m [RX_CMD     ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0008 RD/WR=Write.
    245.326801m [RX_CMD     ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0009 RD/WR=Write.
    256.192801m [RX_CMD     ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x000A RD/WR=Write.
    Until Here it's all good, but...
    Code:
    256.708801m [RX_CMD     ]: Command received: 0xEE (0b11101110). Device=7, Block=0x00, Address=0x0009 RD/WR=Write.
    256.708801m [RX_CMD     ]: Unknown command value (0xEE) received - command is ignored.
    
    266.934401m [RX_CMD     ]: Command received: 0xA0 (0b10100000). Device=0, Block=0x00, Address=0x0009 RD/WR=Write.
    267.134001m [RX_CMD     ]: Command received: 0x0A (0b00001010). Device=5, Block=0x00, Address=0x0026 RD/WR=Write.
    267.134001m [RX_CMD     ]: Unknown command value (0x0A) received - command is ignored.
    
    277.362001m [RX_CMD     ]: Command received: 0xEE (0b11101110). Device=7, Block=0x00, Address=0x0026 RD/WR=Write.
    277.362001m [RX_CMD     ]: Unknown command value (0xEE) received - command is ignored.
    Here it comes, it can't recognize the commands because for example, instead of receive this control byte:
    0b10100000

    it receive this:
    0b00001010
    or this:
    0b11101110

    it's like there's something missing, the eeprom don't receive the whole bytes, maybe the 10MHz OSC is not good?

    Thx...

    Luca

  10. #10
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    oslinux , I have used the 24lc512, 24lc515, 24lc1025 in pairs, to date with out any problem. One thing I did find is that if you are running interrupts during the read or write process I would sometimes have incorrect data ether read or written to the EEPROM. I disable all interrupts during the write process and I haven't had any problems since....

    Dave Purola,
    N8NTA

  11. #11
    Join Date
    Mar 2007
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    no i'm not using interrupts, but aniway i've placed a DISABLE before the write...

  12. #12
    Join Date
    Nov 2005
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Try to split the word in 2 bytes;

    i2cwrite Sda,Scl,Ctrw,Addr,[TmpW.highbyte]
    pause 10
    Addr = Addr + 1
    i2cwrite Sda,Scl,Ctrw,Addr,[TmpW.lowbyte]
    pause 10
    Addr = Addr + 1

    Ciao

  13. #13
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Hoping all is well with the hardware, you need to break the addr part into 2 bytes.

    I2cwrite SDA,SCL,CONTROL,I.HighByte, I.LowByte, [W0]

    I use this in my design and it works correctly with a 24c512

    Jerson

  14. #14
    Join Date
    Mar 2007
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    Solved Solved Solved Solved


    i tried splitting the address in two with no success, but

    i changed the resistors from 0,5W to 0,125W, from 2.2K to 4.7K and now it's working well!

    Thank you all for your support!

    Luca

  15. #15
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    it make no real sense but if it's working...

    How many years/decade/century your Proto-Board (breadboard) have?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  16. #16
    Join Date
    Mar 2007
    Posts
    30


    Did you find this post helpful? Yes | No

    Default

    it's a breadboard from 4 years ago if i remember well, but it has been used for a lot of projects, and not only with wires of the right width!

    I'll use my new proto-board in a better way, I PROMISE

  17. #17
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yeah i see... We all tried to fit over-rated Awg wires + few TO-3 working on +/- 80 VDc and/or 110/220 VAC on those gizmuth

    This remind me few plastic smells experiments...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  18. #18
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Or used a proto-board without the double-sided protective sticky tape on the back and decided it would be a good idea to lay the board down onto something electrically conductive?

    Smoke, sparks, melted pieces/parts, popped circuit breakers, blown fuses, all sorts of fun!!!

Similar Threads

  1. I2CRead & I2CWrite not working as expected
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 30
    Last Post: - 27th October 2021, 18:36
  2. PIC 18F4550 and MCP23017
    By DaveC3 in forum Code Examples
    Replies: 12
    Last Post: - 4th December 2010, 14:01
  3. Puzzling issue with I2CWRITE to 24LC512
    By aberco in forum General
    Replies: 4
    Last Post: - 22nd August 2008, 17:47
  4. My I2CWRITE - timings and tricks
    By FinchPJ in forum Code Examples
    Replies: 5
    Last Post: - 3rd March 2008, 21:40
  5. I2CWRITE and I2CREAD
    By Tomas in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd April 2004, 02:30

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