How to identify a specific character/location (FF) in EEProm??
orendacl
Posts: 44
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.
......· 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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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.
See my previous post - check out the READ and WRITE statements in the Stamp manual.
Regards,
DJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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...
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?
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
- 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.
·
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
"...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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
[/code][/size]