Shop OBEX P1 Docs P2 Docs Learn Events
24LC128 communication — Parallax Forums

24LC128 communication

NB_NesquikNB_Nesquik Posts: 35
edited 2012-11-02 19:49 in BASIC Stamp
I have a 24LC128 external eeprom and a BS2 Homework board and I need help with a two simple codes, one to write to it and one to read from it. I have a sample code that came with the eeproms documentation < 24LC128.bs2 > but I dont know what I need from it, and what is just part of that specific program. My goal is to have on writing program that uploads a bunch of data to the eeprom and then another program that would replace the "get_data:" subroutine in this program <Untitled2newest.bs2> and be able to read the data from the beginning multiple times.

Correct me if Im wrong but I think I need the I2C_Stop, 1C2_Start, Addrs, and Write_Data subroutines from the first program, but Im not sure if I need the Control_Byte_Write or the Control_Byte Read. Also, which parts of the DATA from the second program will I need to write on the eeprom? The program OUTS the data in binary and I thing if the reading program gets the data in binary then it could just OUTS the data as is.

Thanks for your help

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-02 07:07
    You need all the subroutines from the first program. All that program does is write some values to the EEPROM, then read them back. Make a checklist of the subroutine names, then check them off as being used in the main program, then go through the checked list of subroutines and check off any subroutines each calls. Repeat until you don't check anything new. If any are not checked, they're never called.

    I assume you will need all the DATA items in the second program. It looks like a table with two values per entry taking up 3 bytes, one a 16-bit word and the other an 8-bit byte.

    Remember that your second program uses the built-in program EEPROM to store the DATA items. The READ statement reads from the built-in EEPROM and the Stamp Editor stores the DATA items in the EEPROM. You're just substituting another EEPROM for the data and the subroutine calls for the READ statement since the READ statement doesn't know about external EEPROMs.
  • NB_NesquikNB_Nesquik Posts: 35
    edited 2012-11-02 15:50
    Okay, so I looked at the program and I dont understand where the i2cWork.HIGHBYTE , i2cWork.LOWBYTE , and i2cWork.BIT0 came from. They do not look like varriable or any other kind of deffined item. Heres <24LC128 write.bs2> an updated program with what I think it should work (all except for the i2cWork.HIGHBYTE and stuff). Should it work?

    Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-02 16:05
    Read the section of the Basic Stamp Syntax and Reference Manual in the section on Basic Stamp Architecture - Aliases and Modifiers. The modifiers .LOWBYTE, .HIGHBYTE, and .BIT0 allow access to portions of the word variable i2cWork. Although there are other ways to break apart a variable value and reassemble it from pieces, it's clearer and more efficient to use the modifiers.
  • NB_NesquikNB_Nesquik Posts: 35
    edited 2012-11-02 19:49
    Okay, so the program is not working and i dont know why. I really want to get it to work but I dont have time to go in depth trying to learn it right now. I dont want to sound demmanding or needy and ask for a ready-made program, but I really need a working program. I can go back and learn how it work later, but i really need this to work for tommorrow morning. If anybody has a working program, please let me know.
Sign In or Register to comment.