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.
Remember that a byte is made up of 8 bits. Each NVM register holds one byte.
🚩 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.
NVM Bit Map - TODO: update this
Byte Name | Location | Description |
---|---|---|
BOOT_COUNT | 0x00 | Number of times the CircuitPython VM has been initialized. |
Untitled |