Shop OBEX P1 Docs P2 Docs Learn Events
I2C EEPROM Question — Parallax Forums

I2C EEPROM Question

LewisLewis Posts: 23
edited 2007-07-11 04:48 in General Discussion
Hello,

I've been trying to interface a AT25C1024 EEPROM chip with my SX28 and I've been close, but unsuccessful. To start off, and after digging through the datasheet and other I2C resources, I went ahead and implemented very unpolished versions of "write byte" and "read byte" operations in SX assembly... I closely followed the I2C spec for this device and my oscope reading seems to be right on and I even receive all the ACK's from the EEPROM. My problem is that I can't seem to correctly read back the byte that I successfully wrote to (17-bit) location 0x0000. No matter what byte I write to 0x0000, I always get 0xFF back.

Just to let you know, the chip is not write protected. And it is also not a timing issue because I'm stepping through it manually with the debugger... I also swapped the chip for another one and the program behaves the same way.

Here are some figures from my analysis. Have you guys bumped into this issue before? Get all the ACK's and still not be able to retrieve a written byte?

www.ismstudios.com/images/eepromHookup00.jpg
www.ismstudios.com/images/oscopeWriteByteReading.jpg
www.ismstudios.com/images/oscopeReadByteReading.jpg

Please help! I appreciate all your responses.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Lewis [noparse][[/noparse]m80] -

Comments

  • DosManDanDosManDan Posts: 179
    edited 2007-07-10 06:01
    Read the code for the program I wrote in the Completed Projects section of the forum. It has tested code that writes to an I2C EEPROM chip. It isn't the same one you are using, but I2C should be the same for all of them.

    http://forums.parallax.com/showthread.php?p=659734

    Everytime I've run into the problem you describe, it was because of a timing issue. Usually I didn't wait long enough to read back the value I just wrote. You have to wait for a specified amount of time before reading after you do a write. Check the chip specs for this number.

    Dan
  • LewisLewis Posts: 23
    edited 2007-07-10 16:12
    Hey Dan,

    Thank you for the reply and congrats on that cool project that you finished. I did look at your code and your MEM_IN and MEM_OUT routines seem to use I2C* type of commands in SX/B. My goal is to recreate these I2C commands in assembly because I do not use SX/B. Even so, thank you for your reply.

    Has anyone here created I2C routines in assembly that has bumped into the same issue I have?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Lewis [noparse][[/noparse]m80] -
  • Dave HeinDave Hein Posts: 6,347
    edited 2007-07-10 16:41
    Lewis,

    I wrote some SX assembly code for the 24C512 about a year ago. The thread is located at http://forums.parallax.com/showthread.php?p=591787. There is also some good information on interfacing to EEPROMs in the sticky thread called "Best SX Threads index". It is located at http://forums.parallax.com/showthread.php?p=642725.

    Dave
  • DosManDanDosManDan Posts: 179
    edited 2007-07-10 17:30
    Lewis,

    SX/B was written as a training language to help people learn how to write in Assembly for the SX. It generates assembly code that should need minimal cleanup to work.

    My thought was that you would look at working code, then reduce and optimize the Assembly code to get a working program.
    I also belive that Gunther's Assembly book on the SX chip has all the I2C commands you would need. I don't have it in front of me, but I'm pretty sure I read the I2C and SPI commands in that book.·I can check when I get home, or maybe someone else can confirm that in the mean time.

    Dan

    Post Edited (DosManDan) : 7/10/2007 5:36:22 PM GMT
  • LewisLewis Posts: 23
    edited 2007-07-10 19:13
    Dan said...
    It generates assembly code that should need minimal cleanup to work.

    Hey Dan, so I wasn't aware that it we had access to the assembly file before loading it to the SX (when compiling SX/B code). When I run my programs in assembly, they are immediately loaded to the chip--that is why I thought this. So is using SX/B a 2-step process? Compile to assembly, then load to the chip?

    Dave,

    Thank you for your links as well. I will go through those threads now.

    I really appreciate your help so far [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Lewis [noparse][[/noparse]m80] -
  • PJMontyPJMonty Posts: 983
    edited 2007-07-10 19:28
    Lewis,

    Yes, SX/B compiles to assembly and then loads to the chip. The SX debugger/editor/etc all deal with assembly language. Hence, to support BASIC (or any high level language), the simplest approach is to compile into assembly and then let the rest of the IDE do what it does already with assembly language.

    CPUs understand their native machine language, and assembly language is the human readable (mnemonic) version of that. To convert from machine to assembly is a trivial programming task. The hard part is getting the compiler to convert high level code (such as BASIC) into machine code.

    Do you not use the IDE debugger when trying to debug programs? If you do, then you have seen the assembly code the compiler generates. IF you haven't been using the debugger, then you are missing out on one of the single biggest benefits of the SX chip.

    If you simply want to see the assembly listing, hit Run->View List, or use the shortcut CTRL-L.

    Thanks,
    PeterM
  • LewisLewis Posts: 23
    edited 2007-07-10 19:50
    Hey,

    Thanks for the reply PJMonty. I actually do use the debugger often... it's like my best friend. I've been strictly using SX assembly because that's the way I was introduced to the chip a couple of years ago. The funny thing is that I've stayed away from SX/B because it's a non-optimizing compiler. On a PC, when I use Java/C#/C++ or whatever else I need for work, the compiler usually compiles to p-code or byte-code that I would have to reverse engineer with a debugger to view. It's kinda nice that the SX/B simply writes a simple assembler file for me to inspect. The process is a bit different than from what I'm use to, that's all.

    The lesson learned here is that I shouldn't ignore a resource (SX/B) that has proved useful to many others.

    Once again, thank you all for all your helpful replies.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Lewis [noparse][[/noparse]m80] -
  • LewisLewis Posts: 23
    edited 2007-07-11 04:48
    ...And a long week ends in good news! I would like to thank all of you, including Andre' for giving me great tips regarding this topic. This was my first I2C project and it's a great feeling of accomplishment!

    Thanks again!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Lewis [noparse][[/noparse]m80] -
Sign In or Register to comment.