Shop OBEX P1 Docs P2 Docs Learn Events
how to write data and let the BS2p40 to read — Parallax Forums

how to write data and let the BS2p40 to read

PHM102PHM102 Posts: 27
edited 2006-08-14 17:54 in BASIC Stamp
i am doing a project using bs2p40 and we wanted to save name and phone number into the bs2p40 by entering those name and phone no. using several button with an aid of serial 4X20 LCD and we can also read it next time we needed. do anyone have any idea on that how to write the program?
·

Comments

  • T ChapT Chap Posts: 4,223
    edited 2006-08-13 05:07
    In the Basic Stamp Command Reference, lookup "Write". Keep in mind you can only write to the eeprom so many times before you kill it, maybe 100k times?
  • ZootZoot Posts: 2,227
    edited 2006-08-14 17:54
    Here's some simple code that may help get you started.

    FullName   DATA    (40)     '40 characters of "blank" or "undefined" data --
                                     'this way your program won't overwrite your data when you download your program
    Phone   DATA   (10)     '10 character phone number
    
    EEaddr  VAR     Word    'EEPROM pointer
    somedat   VAR      Byte    'some data
    idx       VAR      Byte     'index counter
    
    '...........some code here to run your LCD and buttons
    '....and write into to EEPROM
    
    '...........here's reading the Name -- do the opposite with WRITE to store info entered via LCD
    
    EEaddr = FullName
    FOR idx = 0 TO 39
       EEaddr = EEaddr + idx
       READ EEaddr, somedat
       DEBUG somedat
    NEXT
    
    



    When you are writing your data, just remember to write one byte at a time, as each character will be a byte. Is this helpful?

    Regarding the 100k writes -- search the forums for Andy Lindsey's recent posts regarding "rollover" of often used EE addresses -- basically you move the data around occasionally so that you are not constantly writing to the same locations. But if you are entering phone number/name only once a week or once a month, it will be a while till you hit the limits.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
Sign In or Register to comment.