Writing and reading to a 24LC1025


Closed Thread
Results 1 to 7 of 7
  1. #1

    Default Writing and reading to a 24LC1025

    I am developing a weather station logging system uses a 16F877 and should write 16 bytes of daily data to a 24LC512 EEPROM. Using I2C, I have a DS1307 (which works fine) connected on the same bus as the 24LC512. However, I cannot write or read succesfully to the EEPROM at all. the 3 address pins on the 512 are grounded. After trying unsuccessfully to write & read in page mode, I went back to the "Really simple" example in the PBP handbook, which I still cant get to work - instead of reading a 6 back, I get 255

    Code below:

    '27LC512 READ/WRITE Test
    'DS1307 works fine on SCL and SDA pins below.
    '24LC512 is in parallel with DS1307


    SCL pin VAR PORTC.2
    SDApin VAR PORTC.3
    B2 var byte

    '24LC512 MSB is device code. LSB is device address, all address pins grounded
    cont con %10100000

    'Writetest:
    Lcdout $fe,1:Pause 500
    Lcdout $fe,$80,"Mem read/write test"
    I2cWrite SDAPin,SCLPin,cont,%00001111,[6] 'Write decimal 6 to address 15
    pause 20 'Allow time for write to finish

    ''----------------------------| Now read it back |--------------------------
    I2cread SDAPin,SCLPin,cont,%00001111,[b2] 'Read data at address 15
    lcdout $fe,$C0,#B2:Pause 50
    Idle:goto Idle
    End
    I Get 255 returned in B2 instead of decimal 6

    Any help gratefully received


    Angus Anderson

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Angus Anderson View Post
    I am developing a weather station logging system uses a 16F877 and should write 16 bytes of daily data to a 24LC512 EEPROM. Using I2C, I have a DS1307 (which works fine) connected on the same bus as the 24LC512. However, I cannot write or read succesfully to the EEPROM at all. the 3 address pins on the 512 are grounded. After trying unsuccessfully to write & read in page mode, I went back to the "Really simple" example in the PBP handbook, which I still cant get to work - instead of reading a 6 back, I get 255
    Angus Anderson
    Do a search here on the site for 24LC1025. There was another person awhile back had similar problems with the larger I2C eeproms, got it working with the advice in that thread, something about splitting the address into two seperate bytes in the command line, not really sure.
    Last edited by skimask; - 17th April 2007 at 15:07.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks Skimask. Will report back

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

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


    Did you find this post helpful? Yes | No

    Default

    Angus Anderson, the 24LC1025 is expecting an 16 bit address. You are only sending it an 8 bit address.

    Dave Purola,
    N8NTA

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Dave, you were right about the 16 bit address

    I've managed to solve the problem by:

    1) Making the address a word sized variable
    2) Changing the pullup resistors from 4k7 to 2k7
    3) Taking the data to be stored and saving it Highbyte and Lowbyte so:

    I2cWrite SDA,SCL,$A0,Address,[Databyte.Highbyte]
    Address = Address+1
    I2cWrite SDA,SCL,$A0,Address,[Databyte.Lowbyte]
    Address = Address+1

    It now works like a charm. Thanks all of you for your advice, not the least by being reminded to take the trouble to do a search of the forum first ;-)

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


    Did you find this post helpful? Yes | No

    Default

    Angus Anderson, That's good you got it working. I use 4 of the 24LC1025's for a fishing device I designed and it records 18+ hours of various data.

    Dave Purola,
    N8NTA

Similar Threads

  1. Reading, writing, erasing flash (16F88)
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 8th March 2010, 08:13
  2. Writing & Reading to iButton EEPROM
    By crhomberg in forum Code Examples
    Replies: 2
    Last Post: - 6th October 2008, 19:40
  3. Reading and Writing from SD/MMC cards as FAT filesystem?
    By charliez in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd June 2006, 22:26
  4. reading, writing, and displaying from eeprom
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th January 2006, 22:05
  5. Writing / Reading EEPROM 24LC256 Problem
    By schmoddel in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th February 2004, 18:55

Members who have read this thread : 1

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