I2CWRITE on a 24LC512


Closed Thread
Results 1 to 18 of 18

Hybrid View

  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.

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