Shop OBEX P1 Docs P2 Docs Learn Events
Tutorial - Retrieving EEPROM Data From BASIC Stamp Modules — Parallax Forums

Tutorial - Retrieving EEPROM Data From BASIC Stamp Modules

Qwaszx72Qwaszx72 Posts: 30
edited 2011-04-27 12:37 in BASIC Stamp
Here is a simple tutorial teaching you how to retrieve the EEPROM Data from your BASIC Stamp(BS2 or above):

Comments

  • Qwaszx72Qwaszx72 Posts: 30
    edited 2011-04-26 16:21
    BASIC Stamp 2, 2e, 2sx:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    Read_Location VAR Word
    
    Debug_Data VAR Byte
    
    FOR Read_Location = 0 TO 2047
      READ Read_Location, Debug_Data
      DEBUG HEX2 Debug_Data, " "
    NEXT
    

    *Because the BS2 has only one program slot(The BS2e and BS2sx have more than one program slot yet there is no command which allows you to change which program slot you are reading from), 32 BYTES of data will not be retrievable.
    **Also the format that the EEPROM Data is displayed in is simplified in order to reduce the program size.

    Here is a version of the above code that debugs the EEPROM data in a 128 by 16 matrix:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    Row VAR Byte
    Col VAR Byte
    
    Debug_Data VAR Byte
    
    FOR Row = 0 TO 127
      FOR Col = 0 TO 15
        READ Row * 16 + Col, Debug_Data
        DEBUG HEX2 Debug_Data, " "
      NEXT
      DEBUG CR
    NEXT
    

    *The above code requires 64 BYTES of the EEPROM
  • Qwaszx72Qwaszx72 Posts: 30
    edited 2011-04-26 16:27
    BASIC Stamp 2p, 2pe, and 2px:

    Here is the first program:
    ' {$STAMP BS2px, EEPROM_Debug_1}
    ' {$PBASIC 2.5}
    
    RUN 1
    

    *The above code will take up 16 BYTES from the EEPROM(This is the least that a program can use)

    And here is the second:
    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    
    Row VAR Byte
    Col VAR Byte
    
    Debug_Data VAR Byte
    
    STORE 0
    
    DEBUG "     0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F ", CR
    FOR Row = 0 TO 126
      DEBUG HEX3 (Row * 16), "  "
      FOR Col = 0 TO 15
        READ Row * 16 + Col, Debug_Data
        DEBUG HEX2 Debug_Data, " "
      NEXT
      DEBUG CR
    NEXT
    
    DEBUG "7F0  ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ", CR
    

    *This code is a lot more extravagant because it is on a different program slot and will usually not interfere with the current program on the EEPROM
  • Qwaszx72Qwaszx72 Posts: 30
    edited 2011-04-26 16:29
    Here is some more code that may help you:
    ' {$STAMP BSe}
    ' {$PBASIC 2.5}
    
    RUN 1
    

    *The above program will RUN the program on SLOT # 1; Change the 1 into any number between 1-7 to see if a program in on any of those program slots
    **This program will work on any BASIC Stamp module above the BS2
  • Qwaszx72Qwaszx72 Posts: 30
    edited 2011-04-26 16:30
    I hope you enjoyed this short tutorial on Retrieving EEPROM Data From BASIC Stamp Modules.

    Please post any comments, questions, or fixes that you wish. I will get back to you as soon as I can.

    Also, if you would like me to create more tutorials, please do not be hesitant to reply asking me to do so. Just be sure to tell me what you would like the tutorial to be on.


    Here are the links to my other tutorials:
    BASIC Stamp Debugging
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-04-26 17:27
    Your first program will not work. Read_Location has to be declared as a WORD.

    -Phil
  • vaclav_salvaclav_sal Posts: 451
    edited 2011-04-26 18:20
    Good constructive article. Thanks.
    Next time make sure it does actually works - the DEBUG without CR as last formatting parameter may not be what you wanted.
    I also think that you comment on "32 BYTES of data will not be retrievable" needs explanation.

    If you want to do more tutorials - I would suggest tutorial on program debugging - include DEBUG, DEBUGIN, conditional compilation ( #DEFINE ), STOP etc.

    Also usage of subroutines tutorial would be nice.

    Again, good and much appreciated and needed work, but look up “extravagant”, I am not sure you met that.
  • Qwaszx72Qwaszx72 Posts: 30
    edited 2011-04-27 12:37
    Thanks for pointing out the minor errors, I will fix those. And by the way, the lack of the CR command is so it takes up only 16 Bytes of the EEPROM instead of 32.

    Also, I will begin work on a program debugging tutorial today. Thanks for the suggestion.
Sign In or Register to comment.