I find that a word defined with a defining word does not persist intact after warm restart. Specifically, constants that I would understand to be compiled into the word definition apparently get zeroed.
David,
In FF you can select which data section is used for the created word. Default is ram, so that's why your data area is zeroed. You can also use flash, then the data will be there after a restart.
There is also a data section for eeprom if your chip has eeprom.
:rememberer:create,does>( -- x )@;flash5rememberer:five\ Constant in flashvariablecal1\ Variable in flash (occasional updates only) 1234valuecal2\ value in flash (occasional updates only)deferexecutor\ defer in flash (occasional updates only)ramvariablecounter\ Variable in ram2345valuebla\ Value in ram5rememberer:six\ Not useful
The prompt shows the current data section.
If you want a defining word to always use flash as the data section you can do it like this.
:rememberer:flashcreate,ramdoes>(--x)@;
👍
1
Last edit: Mikael Nordman 2024-04-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Mikael, many thanks for this explanation. In retrospect, I can see that Peter Jacobs's documentation for CREATE indeed clearly states that it "store[s] the current data section pointer"! It had just not occurred to me that a word's instance data might not be contiguous with its code, and I'm aware all instructions on the PIC24 must be in flash.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I find that a word defined with a defining word does not persist intact after warm restart. Specifically, constants that I would understand to be compiled into the word definition apparently get zeroed.
Here's a simple repro:
Are words defined via defining words not supposed to have persistent memory? Or have I misunderstood how to create a defining word?
David,
In FF you can select which data section is used for the created word. Default is ram, so that's why your data area is zeroed. You can also use flash, then the data will be there after a restart.
There is also a data section for eeprom if your chip has eeprom.
The prompt shows the current data section.
If you want a defining word to always use flash as the data section you can do it like this.
Last edit: Mikael Nordman 2024-04-06
Mikael, many thanks for this explanation. In retrospect, I can see that Peter Jacobs's documentation for CREATE indeed clearly states that it "store[s] the current data section pointer"! It had just not occurred to me that a word's instance data might not be contiguous with its code, and I'm aware all instructions on the PIC24 must be in flash.