Persistent Memories

Persistent Memories are a persistent storage location for working with data. It stores a single byte of data at a time. Unlike the accumulator and tilde memories persistent memories are nonvolatile and typically do not reset after a power cycle.
Persistent memories can always be stored and recalled like a tilde memories but are only made persistent en mass once every 15 minutes. If no persistent memories have been altered for 15 minutes it will be made persistent immediately. If one or more have been altered it will queue the changes and make them all persistent after 15 minutes has elapsed since the last storage event. During this time they will not survive a power cycle but are accurate and available for use in tasking.
Because they are common to all tasks on the device they also create an easy mechanism to share data across tasks.
They are denoted by the tilde symbol "$" followed by the memory location and can be found on the persistent memory tab of the task editor. They can also be referenced by the name of the memory location in the persistent memory tab.
Not every device has had persistent memories added yet but the ones that do have 255 memory locations ($0-254).

Naming your persistent memory locations improves the readablity of your code! $Occupancy_State is easier to understand than $54. It also allows you to reorder the persistent memories without rewriting any code.
Persistent memories are written to EEPROM rather than device RAM. EEPROMs have a lower number of write cycles than a RAM so they wear out faster. Because of this you should only use persistent memories for things you really need to be persistent and only update them when necessary.

Many commands can interact with persistent memories, but these are the most common ones that directly affect them.

  • LDA - Load a value into the accumulator from a persistent memory

  • CMP - Compare to the value in the accumulator to a persistent memory

  • STA - Store from the accumulator to a persistent memory

  • Copy - Transmit a message assembled from a set of persistent memories

The persistent memory sheet is not stored as part of an exported task template. (EVT File) It must be exported separately as a CSV file. It will export in Hex or Decimal depending on your current selection and will not import unless the setting matches the value at the time of export.

Syntax

$X Where X is the memory location number.
$string Where "String" is the name of the memory location with no spaces or special characters other than underscore.

Examples

Example 1

{
LDA $43         //Load a value in persistent memory 43 into the accumulator
LDA $TimeOfDay  //Load the value stored in the persistent memory named "TimeOfDay"
CMP $11         //Compare the value in $11 with the value in the accumulator
STA $10         //Store the value in the accumulator into persistent memory location ~10
TX @5,$0,7      //Send out a message comprised of the 7 values in persistent memories starting at ~0.
}

Example 2

Using a block data to interrogate the state of various persistent memory locations.

{
    LDA #0x6C
	 STA $180
	 LDA $Occupancy_State	        //Load Occupancy State
	 STA $181
	 LDA $Humidity_Refresh_State_1	//Load Humidity refresh state
	 STA $182
	 LDA $Humidity_Timer_1	        //Load humidity timer
	 STA $183
	 LDA $Access_Entry_Flag	        //Load access control flag 0=guest 1=staff
	 STA $184
	 LDA $Balcony_Door_State_1	    //Load balcony door state
	 STA $185
	 LDA $Holdoff_State_1	        //Load energy holdoff state
	 STA $186
	 TX $180,2,7	                //Send it out
}