Cross-Bank use of the various RAM
daniel
Posts: 231
I've read the PBASIC Online Help,Tracy Allen's·application notes, Al William's FAQ entries, Scott Edwards' description of BACKUP / RESTORE context saving routines, Peter Verkaik's call-return code and recalled the discussion several years ago of the same.
I just want to be sure that I understand the memory usage of the multi-bank Stamps·correctly.
Are the following statements true:
1. Scratchpad RAM is preserved between bank switching (e.g., RUN).
2. A bank can be used as· an up-to-2Kb RAM (e.g., STORE·+·READ/WRITE), and when used as such, one must keep in mind the·standard write-cycle limitations of the EEPROM.
3. When used as in #2, that EEPROM is preserved across bank switches.
4. Standard RAM is preserved between bank switching (e.g., RUN).· However,·each bank's view of RAM can be viewed as a sort of UNION·(in the C language sense) of all the bank's RAM usage.
5. With something like Edward's BACKUP / RESTORE, can I treat the 26·bytes of general-purpose·standard RAM as dedicated to a bank; that is, with care, I can treat each bank as having its own dedicated 26 bytes of general-purpose RAM, allowing me to pretend that I have (8 * 26) = 208 bytes of GP RAM.
6. Both RAM and Scratchpad-RAM are volitile, banks used as EEPROM RAM are not.
Daniel
I just want to be sure that I understand the memory usage of the multi-bank Stamps·correctly.
Are the following statements true:
1. Scratchpad RAM is preserved between bank switching (e.g., RUN).
2. A bank can be used as· an up-to-2Kb RAM (e.g., STORE·+·READ/WRITE), and when used as such, one must keep in mind the·standard write-cycle limitations of the EEPROM.
3. When used as in #2, that EEPROM is preserved across bank switches.
4. Standard RAM is preserved between bank switching (e.g., RUN).· However,·each bank's view of RAM can be viewed as a sort of UNION·(in the C language sense) of all the bank's RAM usage.
5. With something like Edward's BACKUP / RESTORE, can I treat the 26·bytes of general-purpose·standard RAM as dedicated to a bank; that is, with care, I can treat each bank as having its own dedicated 26 bytes of general-purpose RAM, allowing me to pretend that I have (8 * 26) = 208 bytes of GP RAM.
6. Both RAM and Scratchpad-RAM are volitile, banks used as EEPROM RAM are not.
Daniel
Comments
2. It's not RAM; it is nonvolatile storage.
3. Yes.
4. Yes -- so it you need to preserve variables after run, keep the RAM definitions constant between banks.
5. No; you have 26 bytes of variable RAM. Period.
6. RAM is volitile; EEPROM is not.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
5. With clever tricks like those described by Verkaik, Allen, and Edwards, one can implement a type of virtual memory scheme, swapping those 26 Bytes (less·overhead as required by the trick) into either Scratchpad·RAM or a bank's EEPROM.
Daniel
http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf
Note what he says about "plan your work and work your plan"!
Avoid the temptation to turn the Stamp into a supercomputer with a vast array of memory through a general scheme of memory swapping. That will be slow for sure and unecessary in most cases for things the Stamp will do. A lot of it instead will be ad hoc to solve a particular problem. It does help to be systematic, that is, to understand as you do the capabiltities of the different types of available memory, and then to plan ahead and draw from a bag of tricks that come from experience and example.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thank you, Tracy, for the reference to Jon's article. I had forgotten that one. And thank you for the admonition.
In this particular applications case, I'm trying to avoid going just yet to an SX, and I think that a little virtual memory will do the trick.
Daniel