Settings object question?
I downloaded the ROMEngine object from the obex exchange and I need some help to use it.
I want to write to the 2nd half of the 64k EEPROM on the proto board.
So I know that
is correct but is
correct?
and how does the address increase with a byte, long, etc?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
Post Edited (computer guy) : 1/30/2010 7:12:06 AM GMT
I want to write to the 2nd half of the 64k EEPROM on the proto board.
So I know that
Data_Pin = 28 Clock_Pin = 29
is correct but is
EEPROM_Address = %1010 EEPROM_Size = 65536 EEPROM_Page_Size = 32
correct?
and how does the address increase with a byte, long, etc?
Thank you

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
Post Edited (computer guy) : 1/30/2010 7:12:06 AM GMT

Comments
The EEPROM_Size = 65536, EEPROM_Page_Size = 32 are linked to the manufacturer specification for the EEPROM. If you are using the demo board or any parallax board the values are correct.
You need to verify this information against the EEPROM's data sheet you have otherwise.
The EEPROM address should also be able to be found on the data sheet for the EEPROM you are using.
...
Or·are you having problems with the driver?
The driver allows for direct memory acess to the EEPROM. You don't have to worry about an address increasing or anything else. You just supply the address of where you want the data to go and it goes there. Or you supply the address you want the data to come from and you get it from there.
You post confuses me. If you want to read and write the upper half of the eeprom all you have to do is just say "readByte(64564)" or something of that nature.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Post Edited (Kye) : 1/30/2010 5:09:37 AM GMT
Im using:
to get day_limits from memory. day_limits is defined as
I am using
to save it back to memory
However day_limits[noparse][[/noparse] 0] always comes back as 0 even after setting it to something else. e.g. 9
Anyone know why?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
attach your code to a posting. - Oh sorry forgot it is commercial and you don't want to attach the code
best regards
Stefan
I will paste the code for those that are too lazy to download a single file.
{{ Settings Object v1.0 Robert Quattlebaum <darco@deepdarc.com> PUBLIC DOMAIN This object handles the storage and retreval of variables and data which need to persist across power cycles. By default requires a 64KB EEPROM to save things persistantly. You can make it work with a 32KB EEPROM by changing the EEPROMOffset constant to zero. Also, since it is effectively a "singleton" type of object, it allows for some rudamentry cross-object communication. It is not terribly fast though, so it should be read-from and written-to sparingly. The data is stored at the end of hub ram, starting at $8000 and expanding *downward*. The format is as follows (in reverse!): 1 Word Key Value 1 Byte Data Length 1 Byte Check Byte (Ones complement of key length) x Bytes Data 1 Byte (If necessary) Padding, if size is odd The data is filled in from back to front, so that the size of settings area can be adjusted later without causing problems. This means that the actual order of things in memory is reverse of what you see above. Even though it is written stored from the top-down, the data is stored in its original order. In other words, the actual data contained in a variable isn't stored backward. Doing so would have made things more complicated without any obvious benefit. Limitations/implications: * The maxumum data size is 255 bytes. * Zero-length entries are valid. * The key value of zero is reserved. * Two entries cannot have the same key. * A valid entry must: * have a non-zero key. * have a correct check byte. * have a length which doesn't extend beyond the settings boundary. * The first invalid entry encountered marks the start of free space. TRIVIA: The data format for this object is based loosely on the OLPC XO-1 manufacturing data, documented here: http://wiki.laptop.org/go/Manufacturing_Data }} CON { Tweakable parameters } SettingsSize = $400 EEPROMOffset = $8000 ' Change to zero if you want to use with a 32KB EEPROM CON { Non-tweakable constants} EEPROMPageSize = 128 SettingsTop = $8000 - 1 SettingsBottom = SettingsTop - (SettingsSize-1) CON { Keys for various stuff } DAY_LIMITS = "t"+("D"<<8) DAT SettingsLock byte -1 OBJ eeprom : "Basic_I2C_Driver" PUB start {{ Initializes the object. Call only once. }} if(SettingsLock := locknew) == -1 abort FALSE eeprom.Initialize(eeprom#BootPin) ' If we don't have any environment variables, try to load the defaults from EEPROM ifnot size revert return TRUE PUB revert | i, addr {{ Retrieves the settings from EEPROM, overwriting any changes that were made. }} lock addr := SettingsBottom & %11111111_10000000 repeat i from 0 to SettingsSize/EEPROMPageSize-1 eeprom.ReadPage(eeprom#BootPin, eeprom#EEPROM, addr+EEPROMOffset, addr, SettingsSize) addr+=EEPROMPageSize unlock PUB purge {{ Removes all settings. }} lock bytefill(SettingsBottom,$FF,SettingsSize) unlock PUB stop lockret(SettingsLock~~) PRI lock repeat while NOT lockset(SettingsLock) PRI unlock lockclr(SettingsLock) PUB commit | addr, i {{ Commits current settings to EEPROM }} lock addr := SettingsBottom & %11111111_10000000 eeprom.Initialize(eeprom#BootPin) repeat i from 0 to SettingsSize/EEPROMPageSize-1 if \eeprom.WritePage(eeprom#BootPin, eeprom#EEPROM, addr+EEPROMOffset, addr, EEPROMPageSize) unlock abort -1 repeat while eeprom.WriteWait(eeprom#BootPin, eeprom#EEPROM, addr+EEPROMOffset) addr+=EEPROMPageSize unlock return 0 pri isValidEntry(iter) return (iter > SettingsBottom) AND word[noparse][[/noparse]iter] AND (byte[noparse][[/noparse]iter-2]==(byte[noparse][[/noparse]iter-3]^$FF)) pri nextEntry(iter) return iter-(4+((byte[noparse][[/noparse]iter-2]+1) & !1)) PUB size | iter {{ Returns the current size of all settings }} iter := SettingsTop repeat while isValidEntry(iter) iter := nextEntry(iter) return SettingsTop-iter PRI findKey_(key) | iter iter := SettingsTop repeat while isValidEntry(iter) if word[noparse][[/noparse]iter] == key return iter iter:=nextEntry(iter) return 0 PUB findKey(key):retVal {{ Returns non-zero if the given key exists in the store }} lock retVal:=findKey_(key) unlock PUB firstKey {{ Returns the key of the first setting }} if isValidEntry(SettingsTop) return word[noparse][[/noparse]SettingsTop] return 0 PUB nextKey(key) | iter {{ Finds and returns the key of the setting after the given key }} lock iter:=nextEntry(findKey_(key)) if isValidEntry(iter) key:=word[noparse][[/noparse]iter] else key~ unlock return key PUB getData(key,ptr,size_) | iter lock iter := findKey_(key) if iter if byte[noparse][[/noparse]iter-2] < size_ size_ := byte[noparse][[/noparse]iter-2] bytemove(ptr, iter-3-byte[noparse][[/noparse]iter-2], size_) else size_~ unlock return size_ PUB removeKey(key): iter lock iter := findKey_(key) if iter key := nextEntry(iter) bytemove(SettingsBottom+iter-key,SettingsBottom, key-SettingsBottom+1) unlock PUB setData(key,ptr,size_): iter ' We set a value by first removing ' the previous value and then ' appending the value at the end. removeKey(key) lock iter := SettingsTop ' Runtime sanity check. if size_>255 abort -666 ' Traverse to the end of the last setting repeat while isValidEntry(iter) iter:=nextEntry(iter) ' Make sure there is enough space left if iter-3-size_<SettingsBottom unlock abort -667 ' Append the new setting word[noparse][[/noparse]iter]:=key byte[noparse][[/noparse]iter-2]:=size_ byte[noparse][[/noparse]iter-3]:=!size_ bytemove(iter-3-size_,ptr,size_) ' Make sure that this is the last entry. iter:=nextEntry(iter) if isValidEntry(iter) word[noparse][[/noparse]iter]~~ word[noparse][[/noparse]iter-1]~~ unlock PUB getString(key,ptr,size_): strlen strlen:=getData(key,ptr,size_-1) ' Strings must be zero terminated. byte[noparse][[/noparse]ptr][noparse][[/noparse]strlen]~ PUB setString(key,ptr) return setData(key,ptr,strsize(ptr)) PUB getLong(key): retVal getData(key,@retVal,4) PUB setLong(key,value) return setData(key,@value,4) PUB getWord(key): retVal getData(key,@retVal,2) PUB setWord(key,value) return setData(key,@value,2) PUB getByte(key): retVal getData(key,@retVal,1) PUB setByte(key,value) return setData(key,@value,1) CON {{ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TERMS OF USE: MIT License │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ │is furnished to do so, subject to the following conditions: │ │ │ │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ │ │ │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ }}I hope this helps.
Sorry for posting so much text!!
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
Post Edited (kuroneko) : 1/30/2010 10:13:15 AM GMT
I missed them. I was going from the example that comes with the object.
I missed start and I don't think commit is in the example.
Edit: Is calling commit after every change to a setting a bad thing?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net
Re: always committing data, it certainly slows things down a bit and puts some unnecessary wear on the EEPROM. OTOH it makes sure your data is safe. Your call really.
If I analyse right kuroneko guessed you might have not included calls to the methods start and commit.
The reason why I am insisting so penetrant on ATTACHING code is that if you can read the WHOLE code
you do NOT need to guess around what it MIGHT be. The code shows what are the facts.
My understanding of attaching code is to use the archive-project function of the propellertool and the attachment-manager of the forum-software
like in the picture attached to this posting
best regards
Stefan
That is why I attached the relevent code only.
Kuroneko didn't really guess but rather he noticed that it wasn't in my post and concluded that I wasn't using them.
My problem is now solved and I am very happy.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"powered by Propeller" domed stickers $1.50 - Find them here
Check out my Design and Technology project for my Higher School Certificate www.ecosureblog.net