📋

PyCubed NVM Bit Map & Usage

A region of non-volatile memory (doesn't get rewritten when power is removed) is reserved for various status-bytes.

💡
The NVM bit map provides a concise way of storing important information.
This is useful for quick & low power radio transmissions conveying state of health info (for example).
Using the NVM bits is purely optional. Don't worry about using/maintaining the NVM bit map until you're comfortable with your flight software and ready to start optimizing.

Remember that a byte is made up of 8 bits. Each NVM register holds one byte.

The decimal number 30 can be represented in hexadecimal as 0x1E and in binary as 00011110. Decimal values great than 255 require two bytes, greater than 65536 require three bytes, etc...


🚩 Flags

A single bit can be used as a "flag" representing a true/flash condition of something. For example, a low battery flag could represent whether or not the spacecraft is low power mode.

🔢 Counters

You can use multiple bits as a compact/concise counter for something you don't want to consume an entire byte.


Manual Operation

To read these status bytes manually from CircuitPython:

from pycubed import cubesat

LOCATION = 0 #-status byte location

VALUE_READ = cubesat.microcontroller.nvm[LOCATION]

To write a status-byte manually from CircuitPython:

from pycubed import cubesat

LOCATION = 0 # status-byte location
VALUE_WRITE = 4 # status-byte value. Must be 0-255

cubesat.microcontroller.nvm[LOCATION] = VALUE_WRITE

There are also built-in methods of retrieving common status-bytes:

from pycubed import cubesat

# return the number of times the CircuitPython VM has been initialized
print(cubesat.boot_count)

# set the boot_count status byte to 0
cubesat.reset_boot_count

# read the boot_count status byte again
print(cubesat.boot_count)

Bitflags.py Library

If you look at the contents of the pycubed.py library, you'll see some counter (c_boot , c_gs_resp, etc...) and flag (f_lowbatt, f_solar, etc...) objects created using the bitflags.py library. This just makes it easier to create and use bit flags and multi-bit counters.

💡
TODO explain bitflags.py usage instructions
TODO update NVM bit map table with pycubed.py contents
TODO add V-R3x NVM map as example

NVM Bit Map - TODO: update this

Byte NameLocationDescription
BOOT_COUNT0x00Number of times the CircuitPython VM has been initialized.
Untitled