PDA

View Full Version : from Ram to Eeprom



Daimon
04-10-2007, 06:02 PM
hi there

well, I'm working with a Basic Stamp 2 sx (BS2sx) and an ADC 16-bits. I have a problem.
I'd like to transfer the data stored in the ram from the ADC (shiftin) to the EEPROM.

The program is like this:

value VAR Word

Shiftin data,... [value\17]

I'd like to transfer the "value" word from the Ram to the EEPROM location for example 0.

Does someone know which syntaxe is necessary to do that?

Thanks in advance

Daimon

Mike Green
04-10-2007, 08:14 PM
Look at the READ / WRITE / DATA statements in the PBasic manual.

Daimon
04-11-2007, 01:57 AM
Hi
thanks for answering. Read and write are the syntaxes I tried but I didn't understood why I couldn't see it in the memory map (stamp editor). If I correctly read the manual, variables in the memory aren't shown, even if you put a direct variable in it.

But thanks for the response.

allanlane5
04-11-2007, 02:29 AM
The "memory map" is a picture, made by the IDE, of what the IDE is going to put into the memory of the BS2.

So, if you specify a 'DATA' statement, that data should show up in the "memory map". If you merely specify an address in your code that you're going to WRITE to, well, the IDE doesn't know about that, and so doesn't put that in the "memory map".

Mike Green
04-11-2007, 02:31 AM
If you initialize a data area in EEPROM with the DATA statement, it will show up on the memory map. The editor doesn't know where the READ / WRITE statements will get/put their data, so it can't show that in the memory map.

I suggest that you use the DATA statement (with a label on it) to define the area(s) in EEPROM that you're going to use. It helps insure that these areas are at the beginning of the EEPROM (the program is at the upper end).

Be careful how you use the WRITE statement since you can "wear out" an EEPROM location with excessive (more than about 100,000) writes. In a program where this is done in a loop, you can wear out a location in a couple of hours. The best way to avoid this is to compare the current content of the location with the variable you want to store. If they're already equal, don't do the WRITE like:


READ location,temp
IF temp <> newValue THEN
WRITE location,newValue
ENDIF


This obviously won't help you if the value is constantly changing.

allanlane5
04-11-2007, 04:41 AM
Ah, great minds think alike, and within two minues of each other, too.