stor. Object

The stor. object icon.

The stor. object provides access to the non-volatile memory (EEPROM), in which your application can store data that must not be lost when the device is switched off.

A warning note icon.On the advice of one of our customers, we would like to remind you that, like all other EEPROMs on the market, the EEPROM ICs used in Tibbo devices allow for a limited number of write cycles. As the Wikipedia article on the subject states, the EEPROM "... has a limited life for erasing and reprogramming, now reaching a million operations in modern EEPROMs. In an EEPROM that is frequently reprogrammed while the computer is in use, the life of the EEPROM is an important design consideration."

If you plan to use the stor. object, please carefully consider if the intended mode of EEPROM use will allow the EEPROM to work reliably throughout the entire projected life of your product. For more information, see Prolonging and Estimating the Life of Your EEPROM below.


The stor.size read-only property tells you the amount of EEPROM memory offered by the stor. object. The stor.setdata method is used to write data to the EEPROM, while the stor.getdata method is used to read data from the EEPROM.

Here is a simple example how to save the IP address of your device into the EEPROM:

Tibbo BASIC
dim s as string
dim x as byte
 
s=ddval(net.ip) 'this way it will take less space in the EEPROM (only 4 bytes needed)
x= stor.set(s,0) 'write EEPROM
 
'check result
if x<>len(s) then
	'EEPROM write failure- do something about this!
end if

And here is how you read this data back from the EEPROM:

Tibbo BASIC
net.ip=ddstr(stor.get(0,4))

Note that with the stor. object, addresses are counted from 1, not 0. That is, the first memory location has address 1.

Special configuration area

The EEPROM IC of the device is also used to store certain configuration information required by the device. The memory available to your application equals the capacity of the IC minus the size of the special configuration area.

By default, when you access the first byte of the EEPROM, you are actually accessing the first memory location above the special configuration area. One property — stor.base — returns the size of this offset. On startup, stor.base is equal to the size of the special configuration area, so your program can only access the memory above this area.

You can change stor.base and access the configuration area if needed. For example, you can change the MAC address this way — the next time the device boots up, it will start using the newly set address.


Prolonging and Estimating the Life of Your EEPROM

Here are some ideas on prolonging the life of your EEPROM:


When estimating the life of the EEPROM in your system, consider the following:


stor. Object

Special configuration area

Prolonging and Estimating the Life of Your EEPROM