Shop OBEX P1 Docs P2 Docs Learn Events
24LC256 not working — Parallax Forums

24LC256 not working

FlyingFishFingerFlyingFishFinger Posts: 461
edited 2005-10-30 21:51 in General Discussion
Hello World!
I am trying out my new 24LC256 EEPROM, but for some reason I can't get it to work. It seems to write properly, but all I ever get back from every location are 255's...I'm probably doing something wong, but I can't figure out what. What I have is this for the write copied almost straight from the Stamp Manual:

outgoing VAR Byte
outgoing=5
i2cout 0,$A0,0,[noparse][[/noparse]outgoing]

My read looks loke this:
result VAR Byte
i2cin 0,$A1,0,[noparse][[/noparse]result]
debug dec result

I don't get the address thing, though...
Thanks
Rafael

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-30 04:11
    Do you have the 4.7K pull-ups on the SDA and SCL lines?· Are you initializing the I/O lines properly before that code you have?· This is all assuming the code is correct, which I haven't verified yet.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • FlyingFishFingerFlyingFishFinger Posts: 461
    edited 2005-10-30 04:15
    Well,I have the pull-ups, and as I said the code comes almost directly from the manual. What I noticed is that if I write a 0 to a location, Iget a 255 back, but if I write a 1, I get a 0 back.
    BTW, this is the first time I'm using either EEPROM or I2C
    Rafael
  • FlyingFishFingerFlyingFishFinger Posts: 461
    edited 2005-10-30 04:19
    Nope, not correct. I get a 0 or a 255, regardless what I pretend to write.
    Rafael
  • FlyingFishFingerFlyingFishFinger Posts: 461
    edited 2005-10-30 04:21
    That's not right either. I get a zero when I write a zero, 255 if I write anything else
    Rafael
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-30 04:27
    Try the code located here...It might work.· The accessing scheme looks the same to me.· Your code seems to missing something.

    http://www.parallax.com/detail.asp?product_id=602-00013

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • FlyingFishFingerFlyingFishFinger Posts: 461
    edited 2005-10-30 04:29
    AH, that works, but what does the highbyte/lowbyte stuff do?
    Rafael
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-30 04:46
    It splits the Word variable up into Byte-sized pieces (I know that sounds funny).· Basically, just like SERIN and SEROUT, you cannot use Word sized values.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • FlyingFishFingerFlyingFishFinger Posts: 461
    edited 2005-10-30 04:49
    Hm, makes sense, but why doesn't it work when I use a byte variable and leave out the highbyte/lowbyte stuff?
    Rafael
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-30 04:50
    I'm not sure you're specifying the second byte, and you need that.· Anyway, you should really check over the code and get a handle on how it works.· That will help you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • FlyingFishFingerFlyingFishFinger Posts: 461
    edited 2005-10-30 04:55
    I get the rest of the code, but I guess I should reread the I2c section. Why do I need the second byte if the protocol only sends one address byte (it says the second one is optional)?
    Rafael
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-30 04:59
    I'm not sure what you're referring to exactly?· Perhaps you should post the data you're quoting from so we can answer these questions.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • FlyingFishFingerFlyingFishFinger Posts: 461
    edited 2005-10-30 05:04
    Never mind, I think I get it. If I replace the address word variable with a byte sized one, I can only store to the first 255 locations (that seems to work)? I only need the word-sized one if I'm storing in higher locaions, correct?
    Rafael
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-30 18:51
    Not sure...I use the code as it is intended.· It doesn't use up any more variable space to decare the low-byte and high-byte of the variable in the parameter.· Besides, what's the point in having a big chip like that if you're only going to use 256 locations?· 99% of people will have that much free in the on-board EEPROM of the BASIC Stamp Module.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • FlyingFishFingerFlyingFishFinger Posts: 461
    edited 2005-10-30 19:27
    Oh ok, I can use that program the way it is. I found that if I use a word-sized variableand highbyte\lowbyte , the code I write myself works too. I guess that I shouldn't worry about trying to use a byte sized variable "just for the fun of it" anyway because I have to use a word to accomodate the large number of possible addresses in that EEPROM, which I will probably need for data storage.
    Thanks Chris
    Rafael
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-30 21:51
    Try not to think of it as two variables (LOWBYTE & HIGHBYTE).· I think that's what's making you think you're dealing with more than you need to.· If you need to address an address higher than 255, then you will need a Word variable to hold the address.· The subroutine handles sending one half at a time.· And since it's a subroutine it doesn't need to be altered for other changes in your program.· Set the address and the data and call the subroutine.· When you want to read a byte from the EEPROM set the address and call the subroutine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.