External EEPROM can't read/write


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Las Vegas, Nevada, USA
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Huh, you don't know what ". . ." means?

    I don't mean to be rude but the ". . ." means that I omitted code from the post or did you want three pages of the same thing over and over?

    I also have no idea what colons have to do with anything.
    Last edited by coyotegd; - 8th May 2008 at 08:19.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by coyotegd View Post
    I don't mean to be rude but the ". . ." means that I omitted code from the post or did you want three pages of the same thing over and over?
    But have you tried the above suggestions at all?

    I also have no idea what colons have to do with anything.
    That's sort of a semi-inside-joke. Don't worry about it. (I have a tendency to write code with a load of colons in it to make more of it fit on each screen)

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Instead of using addr.highbyte,addr.lowbyte in your I2CREAD / I2CWRITE lines, try using
    just addr. PBP already knows addr is a word and will handle both high & low bytes of the
    address for you.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Oct 2005
    Location
    Las Vegas, Nevada, USA
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Simple example; still doesn't work

    I wrote a very simple program but with the same output result:

    5, 57
    5, 255

    Code:
    DEFINE	LOADER_USED	1
    DEFINE    OSC 20
    
    edata     var	  BYTE
    
    pause 100
    i2cwrite portc.4,portc.3,160,5,[57]
    pause 10
    serout2 portc.6,32,[dec 5,44,32,dec 57,10,13]
    i2cread portc.4,portc.3,160,5,[edata]
    serout2 portc.6,32,[dec 5,44,32,dec edata,10,13]
    end
    I tried using portc.0 as SDA and portc.1 at SCL with the same result. I used a different 16F877. It just doesn't make any sense to me anymore. I've checked the datasheets and my circuit many, many times.
    Last edited by coyotegd; - 8th May 2008 at 17:56.

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Have you tried scoping the SCL and SDA lines to see if it is really communicating? I2C is a no-brainer - if you get it working the first time.

    The address should be declared in a WORD sized variable for the 24LC256. You then use this variable to hold the addresses for access.

    Code:
    Address  var  Word             ' this will hold the 16 bit word address
    EData     var  Byte             '  Eprom data byte for read/write
    
    Address = 5                      ' address to access
    Edata    = $55                   ' data to write
    I2Cwrite SCL,SDA,$A0, Address, [EData]   ' write it
    Edata = 0               ' destroy the value before read
    I2Cread SCL,SDA,$A0, Address , [EData]   ' read it back
    if Edata = $55 then Success                   ' if it compares, You Succeeded

  6. #6
    Join Date
    Oct 2005
    Location
    Las Vegas, Nevada, USA
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Exactly, a no brainer

    It's the fact that this should be a "no brainer" that is so baffling. I've breadboarded much more complicated circuits, yet this simple EEPROM circuit won't work. I thought perhaps someone else had encountered this type of problem before and knew of a solution or could identify a source for troubleshooting.

    A digital probe pulses away on both SCL and SDA during read/write ops.

    BTW, I scoped portc.4 and c.3 outputs and SDA and SCL appear to be working. See Scope.jpg with data on top and clock on bottom. Both high prior to write/read operation and data high, clock low after write/read op. However, after a couple minutes, the clock goes high. I have no idea why.

    The write-data signal doesn't change thoughout the write process and it's the same for the read-data signal, but the read signal is not the same as the write signal. See Scope2.jpg.
    Attached Images Attached Images   
    Last edited by coyotegd; - 11th May 2008 at 21:50.

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


    Did you find this post helpful? Yes | No

    Default

    Those waveforms look pretty bad.

    For sure you need a lower pull-up resistance. 2KΩ is recommended for 400khz operation.
    <br>
    DT

  8. #8
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Must have something to do with the multiplexed peripherals on RC3/4. I couldn't identify what could be the cause, but you could try to load the TRISC register yourself and define I2C_INTERNAL in case you want to use the internal I2C engine. There is something about the SSPSTAT reg too. Maybe you should look at those. I cannot comment since I havent used the 877 yet.

Similar Threads

  1. 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
  2. Replies: 1
    Last Post: - 28th January 2010, 22:15
  3. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 06:26
  4. Internal EEPROM Read/write Addressing Errors with 18F PIC's
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 18
    Last Post: - 12th July 2005, 19:42
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

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