PDA

View Full Version : Saving variable values - isopodX


kneedown
10-09-08, 12:35 PM
I'm using an IsopodX and want to save the value of a variable so that it will be available the next time the IsopodX is switched on. Is there an easy way to do this?

ddlawrence
04-22-09, 11:28 PM
I have this same problem. I would like to count certain error conditions in my application to help troubleshoot customer complaints. SAVE-RAM doesn't fit the bill. Can I just write to
an address in flash memory?


thanks..............don

RMDumse
04-23-09, 08:45 AM
Oh, yes, sure. There is data flash available.

Clear it with <addr> EERASE which wiil clean a whole page (256 locations).

Store it with EE!

Read it with @

The available locations varies a bit between revisions, as the SAVE-RAM image is also there, but last I used was in a program was the 1800 and 1900 pages.

ddlawrence
04-27-09, 11:02 PM
OK thanks. That looks easy enough...........don

ddlawrence
05-07-09, 09:16 AM
Hi. I am having difficulty with EE! . I am doing it like so:

VARIABLE ERRCOUNT EEWORD
blahblah
ERRCOUNT @ 1+ DUP ERRCOUNT ! ERRCOUNT EE!

This increments a counter every time an error condition occurs.
But on power down, the counter is reset.
Am I missing something?

thanks.....don

RMDumse
05-07-09, 09:33 AM
The thing about EE or Flash is that it can be written from 1's to 0's, but not from 0's to 1's. So if you store FFFE you will have written a 0 in the least significant bit. To get that 0 out you have to erase the Flash. Storing 0001 into the location makes all the other bits 0 as well, but does not reset the least significant bit back to a 1.

So you are overwritting each EE! and making bits zeros, but never again resetting ones.

Consider this bit of code:

: EESAVE
RESULTFLASH @ FFFF = NOT
IF
RESULTFLASH EEERASE
THEN
RESULTFLASH EE!
; EEWORD

This checks to see if any 0's are already stored in the location, and if they are, first erases the location, before continuing.

Remember with Flash the minimum you can erase is a page size, so erasing something at 1800 will also erase everything from 1800 to 18FF.

So you need to do more management with Flash than you do with just RAM, where you only have to worry about storing, and never about erasing.

ddlawrence
05-07-09, 07:47 PM
Hi. Thanks for the explanation. It is more than I realized, but I really need to do this. I will have to bone up on memory management on the 'Pod. I will have to get the flash addresses of my variables and arrange them so I am not erasing those that are are not being changed from their initial state. Is there a doc for this?
Also, is it necessary to update the RAM variable and it's corresponding flash address? When I do a fetch, it fetches from RAM does it not? Or can I do an EE@?

thanks.....don

RMDumse
05-08-09, 01:19 AM
I will have to get the flash addresses of my variables and arrange them so I am not erasing those that are are not being changed from their initial state. Is there a doc for this?

A doc for managing Flash? Not that I know of.

One scheme, if you have more variables than Flash pages, is to keep a RAM page, and update the RAM, and then also keep a Flash page copy, and only write the Flash when you change something in RAM, or a more sophisticated version would be to update the Flash as you lost power, but that would take some very careful power fail and prediciton monitoring, and having enough capacitance to be sure there would be time during power down to get that RAM copied to Flash.

But then, don't make it harder than it has to be. Just remember the limitations of Flash, that you have to erase a page at a time, because it is Flash and not EE which really can be erased a location at a time.

Also, is it necessary to update the RAM variable and it's corresponding flash address?

Kind of an odd question. RAM is where RAM is, and Flash is where Flash is. There isn't a layer of RAM infront of Flash. So I'm not sure I understand the question.

When I do a fetch, it fetches from RAM does it not? Or can I do an EE@?

A fetch is an access of data memory, whether there be RAM or Flash there.

ddlawrence
05-15-09, 09:29 PM
OK. I had a few misconceptions about RAM & flash. I only want to save 2 or 4 variables. If I declare them after all the other variables I will not wipe out any other variables inadvertently when I do an EERASE. Is that correct?

thanks......don

RMDumse
05-15-09, 10:59 PM
Still some misconceptions. Ram is at one address. Flash is at another. They don't overlap.

So defining variables will make them in RAM. Use constants above 1800 hex for Flash variables, and space one every 100 hex locations. Then when you EERASE them, they will be separate from everything else (except all 256 decimal locations in that page will be erased along with your variable at the beginning of that page. But no problem. EE! the value you want to save in flash at its page address.

So

VARIABLE TEMP1
VARIABLE TEMP2
HEX
1800 CONSTANT FLASHVAR1
1900 CONSTANT FLASHVAR2



: FLASHVAR1! ( n --- )
FLASHVAR1 EERASE FLASHVAR1 EE!
;

Hope that's clear.