Help with i2C eeprom


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Question Help with i2C eeprom

    Gidday,

    I got some 24LC256 Eeprom samples the other day and I've been trying to learn the in's and out's of I2C programming!

    I've come unstuck. Not sure that the problem is with my configuration or what???

    Can some one have a quicky look at my code and put me in the right direction.. taa.

    Code explanation is pretty straight fwd taken from pic compiler sample codes...

    Thanks
    J
    Attached Images Attached Images

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


    Did you find this post helpful? Yes | No

    Default

    Control Byte must be 8 bits... not 9...and you don't have to modify it. I2CREAD/I2CWRITE will handle it for you.

    One other thing, not sure of me for that one, I don't know if...
    I2CREAD plahplahplah...[MyVar]
    wich MyVar is pre-define as a word sized variable is a valide statement. BUT
    I2CREAD plahplahplah...[MyVar.LowByte,MyVar.HighByte]
    Is a valid statement.

    NOW...
    Quote Originally Posted by YourCode
    DEFINE I2C_SLOW 1 'Use for >8MHz OSC with standard speed devices
    DEFINE I2C_SDA PORTB,1 'Data pin for I2C (12-bit core only)
    DEFINE I2C_SCL PORTB,4 'Clock pin for I2C (12-bit core only)
    SSPSTAT.7=0
    SSPSTAT.6=0
    SSPCON.5=1
    SSPCON.4=1
    SSPCON.3=1
    SSPCON.2=0
    SSPCON.1=1
    SSPCON.0=1
    Duh???
    Last edited by mister_e; - 16th March 2006 at 03:32.
    Steve

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

  3. #3
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Talking

    Thanks Steve,

    Got it!

    Yeah I was trying to follow the F88 data sheet, eeprom data sheet, and Picpro manual and got all muddled up!

    It's suprising that I2CREAD/I2CWRITE handles the control byte, I really thought that I had to manually modify it.

    Looks like I2CREAD/I2CWRITE handles the register stuff too. :--)

    Okay, well I've attached an updated code listing for anyone interested in programming a I2C EEPROM chip.

    (I'm only doing this because this forum keeps putting a banner at the top of the page telling me to Post something!!!)


    Cheers
    Jared
    Attached Images Attached Images

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


    Did you find this post helpful? Yes | No

    Default

    I2CREAD/I2CWRITE ae software solution and don't use the internal MSSP module. Easier but slower.. no big deal depending the application
    Steve

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

  5. #5
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Default

    Steve,

    You wouldn't be able to give us a few examples of the "other" faster method that uses the MSSP module.

    I think this is what I was trying to do in the first place when I became unstuck.

    Cheers
    J

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


    Did you find this post helpful? Yes | No

    Default

    I could.. but those MSSP routines (i2C master/Slave, SPI master/Slave) took me awhile to figure and become stable, mature, plahplahplah... There's some nifty code example on the Melabs website.

    Do you really need higher speed btw?
    Steve

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

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. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  3. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  4. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  5. Pic16F628A and 24LC256 EEPROM I2C
    By Mike96 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st January 2006, 03:13

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