Shop OBEX P1 Docs P2 Docs Learn Events
How to identify a specific character/location (FF) in EEProm?? — Parallax Forums

How to identify a specific character/location (FF) in EEProm??

orendaclorendacl Posts: 44
edited 2010-05-12 19:34 in BASIC Stamp
Hello, I am using a BS2 and my memory map looks like this:

......· 0· 1·· 2· 3·· 4··5·· 6·· 7·· 8·· 9· A·· B· C·· D· E· ·F
000 32 32 32·30 44 39 36 34·43 46 FF FF FF FF·FF FF
010 FF FF FF FF FF FF FF FF FF FF FF FF FF FF

I would like to create a FOR loop so that a write routine will look at my EEprom,
and determine where the start of FF is. As you can see, each item from 32 to 46 is
10 characters long. I·do not wish to overwrite this but currently I am doing that.
That's not good!!!
I would like to step such that my write routine will·look for the first instance of FF, then perform its write.
Thanks.

Comments

  • davejamesdavejames Posts: 4,047
    edited 2010-05-12 17:00
    Are you in control of the data being written?

    If so, just keep track of the last EEPROM address accessed. Then increment that address and perform the write.

    A search loop will certainly work, but doing the search EVERY time you want to write data will take increasingly more time.


    Regards,

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • orendaclorendacl Posts: 44
    edited 2010-05-12 17:00
    for my previous post, the manual specifies using something like a pointer such as using a Data @...

    Does anyone know specifically what area of the manual to center in on? I am currently using a Write statement that places all my information in eeprom but as said, the statement does not know where to start writing so it overwrites stuff I wish to keep!!

    Would (and I read an area of the tmanual that talks about the DATA "AT"

    DATA @ $FF
  • davejamesdavejames Posts: 4,047
    edited 2010-05-12 17:03
    DATA is kinda like a directive that will stuff EEPROM memory when the program code is transferred to the Stamp.

    You need to look at the READ and WRITE statements in the Stamp programming reference, or in the Stamp editor help. You most certainly need to supply the WRITE statement with the target address along with data to be written.

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • orendaclorendacl Posts: 44
    edited 2010-05-12 17:06
    Sorry, Dave.

    I just made my post after·missing·your reply. You wrote:

    ________________________________________________________________________________________

    Are you in control of the data being written?

    If so, just keep track of the last EEPROM address accessed. Then increment that address and perform the write.

    A search loop will certainly work, but doing the search EVERY time you want to write data will take increasingly more time.


    Regards,

    DJ

    ________________________________________________________________________________________

    To answer your question, Yes I have absolute control of the data being written.·Could you please direct me to an example of an area of our bs2 manual that I should read up on? I really appreciate your reply.·One last thing,·my·search only needs to happen two possible times. That is, I am in control of the data being written but am only allowing the data to be written twice. The only possible change to that statement is that I am going to include a routine that allows me at will to remove the very items written upon which a maximum of three items would be allowed to be added back into eeprom.
  • davejamesdavejames Posts: 4,047
    edited 2010-05-12 17:10
    No prob, and you're most welcome.

    See my previous post - check out the READ and WRITE statements in the Stamp manual.


    Regards,

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • orendaclorendacl Posts: 44
    edited 2010-05-12 17:17
    Hey, Dave. thanks.

    I had one more thing to add. The reason why I prefer a search is that it will always locate the $FF instance. That way it knows without my intervention where to start from. I do not wish for it to start looking at a set location I tell it. I am going to go back into the manual and see what I can find in the write portion, and hopefully it shows me where I can find information of how to (search for a location). It's a pretty big manual and I get lost on tangents like DATA @, and pointer to...
  • orendaclorendacl Posts: 44
    edited 2010-05-12 17:44
    Looking at the manual I came up with this but it doesn't seem to write in a location...well, let me just say that I do not know where it writes to as I cannot see it as my bs2 is in an enclosure. I take it out to progam in using a carrier board.

    The program loop I am trying to make work is as follows: Note, there was an example on page 190 of the manual.

    FOR idx = 0 TO 9
    ··· idx = idx + 1
    ··· IF char = $FF THEN
    ······ WRITE (do something here)
    ······ ENDIF

    ···NEXT

    Question is, still, how do I get the thing to locate just where $FF is?
  • davejamesdavejames Posts: 4,047
    edited 2010-05-12 18:06
    OK - so you have a FOR/NEXT loop.

    Inside the loop, use the FOR/NEXT counter as the address from which to READ. The READ statement takes two arguments; address and a variable in which to stuff the data read from EEPROM.

    Check that variable's content for being equal to FF (hex) or 255 (decimal).


    ***if all you wish to do is check for FF, then skip the next paragraph.

    If the check is true, then WRITE the desired data to EEPROM. The WRITE statement takes two arguments; address and data to be written. The data can be held within a variable, so the variable would be used in that argument position.

    Go through the loop again, incrementing the counter and thus, the EEPROM address.

    Yea/Nea?

    BTW - the Stamp programing reference manual can be downloaded from the Parallax site as a pdf.


    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (davejames) : 5/12/2010 6:11:50 PM GMT
  • orendaclorendacl Posts: 44
    edited 2010-05-12 18:48
    Thanyou, Dave. One last thing:
    - does the counter in the FOR NEXT need a STEP ?
    example:

    FOR char = 0 to 9 STEP 1

    (I am trying to step 10 spots...or at least looking at my Memory map, that is where FF is.)
    Yes, I am just trying to lcoate the FF. MY write actually works but it does not know where to write at
    so it places the information directly overtop of information at address 0.
    ·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-05-12 19:19
    STEP is only required if the STEP is anything other than 1:

    FOR a = 0 TO 9

    The Stamp "knows" to count backward (implied "STEP = -1") if the argument is arranged that way:

    FOR a = 9 TO 0
  • davejamesdavejames Posts: 4,047
    edited 2010-05-12 19:23
    No, it does not requre a "step".

    "...it places the formation directly overtop of information at address 0" - yes, because the FOR/NEXT loop counter in this particular case starts at 0, and then the WRITE statement uses that value in which to deposit data.

    How about this...PM me with the details of your project and let me mull it over for a bit.

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-05-12 19:34
    ·
    [size=2][code]
    eeprom_scan:
      a = 0
    more:
      READ a, scan
      IF scan = $FF THEN Vete
      a = a + 1
      GOTO more
     
    Vete:
      "go on with whatever"...
    


    [/code][/size]
Sign In or Register to comment.