I need help with i2c memory


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    hey! its working,
    the problem i was having was in declaring tris when reading/writing to the memory. ive got it working now and am very happy. thankyou all for the help, heres my current code,

    trisb=%00000010 'read i comment one out
    'trisb=%00000001 'write
    addr var byte
    sda var PORTB.0
    scl var PORTB.1
    cont con %10100000
    x var byte 'test data
    y var byte 'read data


    'x=%00000001 'test data is the number 0'

    addr=0
    loop:

    'I2Cwrite sda,scl,cont,(addr),[x] 'comment out when reading
    'pause 20
    i2Cread sda,scl,cont,addr,[y] 'should read the data
    pause 20
    serout portb.2,4,[254,1]

    serout Portb.2,4,["y=",#y," x=",#x," a=",#addr] 'visual verification
    addr=addr+1
    'x=x+%00000001

    if addr=255 then end

    goto loop

    end

  2. #2
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    I have used external I2C EEProm on a number of projects and have NEVER had to change the TRIS statement to get things to work. Also you STILL have you address variable as a byte, it needs to be a word.

    There is still something horribly wrong with either the software or hardware.
    Last edited by DynamoBen; - 23rd June 2005 at 18:45.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    In your first message, you mentioned 2 different EEPROMs.

    24AA512 and 24c01

    Which one are you currently having success with?

    The 24AA512 is a 64Kx8 device and needs a WORD sized address.
    The 24c01 is a 128x8 and only needs a BYTE sized address.

    My guess is that you're using the 24c01.

    If that's the case, then your test routine loops through 255 address locations, which is double the actual size of the EEPROM. Anything above 127 will loop around and display the first 128 again. Of course, it's just a test routine, but just wanted to let you know.

    Best regards,
       Darrel

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. A help with Write/Read a I2C memory
    By Eugeniu in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 28th March 2008, 13:53
  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