Another attempt for I2C eeprom, this time - 25C256.


+ Reply to Thread
Results 1 to 21 of 21
  1. #1
    Join Date
    Feb 2013
    Posts
    858

    Default Another attempt for I2C eeprom, this time - 25C256.

    Hello.
    I decided to give it another try, now with this module.

    https://www.elecrow.com/i2c-eeprom-m...256-p-736.html

    Pull up resistors installed, and following code configured.
    when properly working, it should produce chirp up, chirp down sound. But it does not
    of course, chirp up - write, works fine, because here it chirps directly, but in read routine
    I'm getting zeros.

    Only what I've found out, that if I set read address to 160 (A0) it returns 255, for any other address, it returns 0.
    So somehow, chip responds, right? but not completely.
    What I'm missing?

    Code:
    x var byte
    y var byte
    z var byte
    sda var portb.1
    scl var portb.0
    
    
    ehmo:
    for X=0 to 12 
    I2CWrite sda, scl, 160, x, [x]
    hpwm 1,127,1000+x*10
    pause 1
    next
    hpwm 1,0,1000 'mute
    pause 500
    
    
    for x=12 to 0 step -1
    i2cread sda, scl, 160,x,[y]
    hpwm 1,127,1000+Y*10
    pause 1
    next
    hpwm 1,0,1000
    pause 500
    goto ehmo

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    For read try 161 address

  3. #3
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    No difference - already tried all combos like 159+160, 160+161 and so on....

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,413


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    The 25C265 as mentioned in the title is a SPI EEPROM. That won't ever work with the I2C command.
    If, on the other hand, it's the 24C256 then the state of the A0-A2 pins will have an effect on the address. Anyway, looking at the 24C256 datasheet:
    In Byte Write mode the Master sends a START, followed
    by Slave address, two byte address and data to be written
    (Figure 6).
    And then your code:
    Code:
    I2CWrite sda, scl, 160, x, [x]
    You're using the x-variable as the address (and data) but have it defined as a byte.

    With that said, I have not ever used I2C so I'm certainly no expert.

  5. #5
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    Yes I made an error in tittle, chip is certainly 24C256.

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    you need to do it properly

    Name:  c1.jpg
Views: 74
Size:  30.4 KB
    Last edited by richard; - 14th January 2022 at 22:21. Reason: can;t type
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  7. #7
    Join Date
    Apr 2014
    Location
    Northeast
    Posts
    486


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    C1, if you have the spare cash, I would recommend a cheap logic analyzer. Saelig sells one for (I think I paid) around $80 US. I haven't used mine in several years, as I now have a Pico Scope that does much more, and better. I am in the northeast US. If you're willing to cover shipping, you can have my old Saelig. It will help you to verify communication protocols and baud rates for situations like this. If interested, PM me & we can take it from there. You might be able to find one on eBay, Amazon, or Craigslist (or whatever local online sellers site you have) for next to nothing, and with cheaper or even no shipping.

  8. #8
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    So what's wrong with 160? it is chip address, A0, and isn't that fixed?

    Regarding the logic analyzer. I have that saelae thing.
    I can't get it work as I understand it should work - run continuously, monitor bytes, like scope does. it only has "run", it runs, fills up buffer in couple of seconds and stops - that's all. For that purposes, I bought a scope with built-in logic analyzer, which can run infinitely - Hantek DSO2D10 - but was able it to work only very low speeds, for protocol decoding.

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    it a constant , pbp constants are 16 bits , i2c address are 8 bit
    use your logic analyzer
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  10. #10
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    So what should I write instead of 160?

    I've searched this forum, and people do use plain numbers in I2C eeprom write/read?

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    Address var byte
    Address = 160
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  12. #12
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,413


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    Yeah, you really should spend some time getting that logic analyzer working and understand what it does. It's NOT an oscilloscope and although newer versions of the software does allow it to continously stream and display that's not really its intended purpose.

    Anyway, here's what I'd try (and I'd have the logic analyzer hooked up)
    Code:
    Chip_Address	VAR BYTE
    Mem_Address	VAR WORD
    sda		VAR portb.1
    scl		VAR portb.0
    
    Chip_Address = 160
    
    ' The chip address must be a BYTE, this is the 160 + whatever A0-A2 is set to.
    ' The memory address must be a WORD for the 24C256, this is the address of the byte to written (or read)
    ' The data to be written is, in this case, a BYTE but it does not have to be, you can write words or arrays - which are obviously just multiple bytes...
    
    FOR Mem_Address = 0 to 12
      '        I/O  I/O       BYTE        WORD             BYTE
      I2CWrite sda, scl, Chip_Address, Mem_Address, [Mem_Address.LOWBYTE]
    NEXT
    And I'd like to thank Richard for the primers on PBP I2C the last couple of days, much appreciated!

  13. #13
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    WOW! Finally it works!

    Code:
    x var word
    y var byte
    adr var byte
    sda var portc.0
    scl var portc.1
    lcdout $fe, $01, " "
    adr=160
    
    
    for X=0 to 5 
    I2CWrite sda, scl, adr, x, [x.lowbyte]
    lcdout $fe, $14, dec x
    
    
    pause 100
    next
    pause 500
    lcdout $fe, $1, "Complete:" 
    lcdout $fe, $c0, " "
    pause 500
    
    
    for x=0 to 5  
    i2cread sda, scl, adr, x, [y]
    lcdout $fe, $14, dec y
    pause 100
    next
    stop
    That's very good, this means now I can do a lot of LCD things!

    Thanks everyone!

    by the way, I tried to write 160 directly, instead of adr - also works.

  14. #14
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    Now I need bitwise hex editor - one that allows editing hex file by bits, not by bytes. Any ideas

  15. #15
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,413


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    Not directly and the following isn't a hex editor but if it's intended purpose is to create "content" for LCDs then https://www.mikroe.com/glcd-font-creator might be what you're looking for.
    Here's another one https://www.buydisplay.com/lcd-font-maker and another https://kapusta.cc/2020/03/20/fontedit/

    I've not used any of them, I know Richard is using the one from MikroE.

  16. #16
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    Yes I know all these
    The issue with Mikroe "creation" is it, as everything else done by them, is written with left feet- need admin priviledges to run it, and it outputs fonts rotated by 90 degrees
    But currently I don't need font editor or graphics editor, I already have all that done, just need some hex editor to put everything into single file and adjust bits as necessary.

    Oh and another issue, which deserves separate topic is how to emulate LCDOUT statement, because it can't send $FE to display

  17. #17
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    Not exact match, but HxD hex editor does the job almost in the way I see it.

  18. #18
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    The issue with Mikroe "creation" is it, as everything else done by them, is written with left feet- need admin priviledges to run it, and
    make an icon and assign admin to it , not a problem. running in compatibility mode can help if it wont save stuff w10 is ok without it

    it outputs fonts rotated by 90 degrees
    glcd mode is data by column, tft mode is data by row , there is no problem
    you need to massage the data a little for pbp but its no big deal
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  19. #19
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    I don't see any mode selector in GLCD font creator from their website.

  20. #20
    Join Date
    May 2013
    Location
    australia
    Posts
    2,090


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    don't think you looked too hard

    Name:  Screenshot 2022-01-17 081202.jpg
Views: 56
Size:  63.5 KB
    Warning I'm not a teacher , prose like a gushing embroilment is not my style

  21. #21
    Join Date
    Feb 2013
    Posts
    858


    Did you find this post helpful? Yes | No

    Default Re: Another attempt for I2C eeprom, this time - 25C256.

    Thanks a lot !
    At my system, that menu bar was not visible at all
    and in file/edit menu, they have no such setting...

Similar Threads

  1. i2c non-eeprom examples?
    By justDIY in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 22nd January 2010, 18:07
  2. Using eeprom for the first time- Help please
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th October 2009, 03:16
  3. Help with i2C eeprom
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 17th March 2006, 00:33
  4. Real Time Clock & Eeprom
    By smart_storm in forum General
    Replies: 8
    Last Post: - 17th February 2006, 19:03
  5. I2C EEPROM Programming
    By Rob in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd March 2005, 15:03

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts