Black Lives Matter - Action and Equality.
0

Memory read/write
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Memory read/write

by Mike1313 on Sun May 17, 2020 2:16 am

With my Feather M4 Express I want to read/write an integer number (1 to 10) to (non volatile) memory on the board.
As a beginner and being in a Circuit(Python) learning process, I am struggling with this problem.
Do I have to use a "Bytearray"? Or can I make a small textfile in memory (in the CIRCUITPY directory?), where I can read and write this number?

It's hard to find any simple example....

Mike1313
 
Posts: 29
Joined: Sat Nov 15, 2014 10:32 am

Re: Memory read/write

by dastels on Sun May 17, 2020 11:05 am

If you start CircuitPython with the flash drive writable to it you could write/read to/from a file. See https://learn.adafruit.com/circuitpython-essentials/circuitpython-storage for how to do that.

Dave

dastels
 
Posts: 2473
Joined: Tue Oct 20, 2015 3:22 pm

Re: Memory read/write

by jerryn on Sun May 17, 2020 1:19 pm

you might also be interested in the nvm module taht uses a reserved area of the flash for as an NVM bytearray


Code: Select all | TOGGLE FULL SIZE
Adafruit CircuitPython 5.3.0-rc.0-24-gb351e9b25 on 2020-04-24; Adafruit Feather M4 Express with samd51j19
>>> import microcontroller
>>> microcontroller.nvm[0]
255
>>> microcontroller.nvm[0]=10
>>> microcontroller.nvm[0]
10
>>> len(microcontroller.nvm)
8192
>>>


jerryn
 
Posts: 1238
Joined: Sat Sep 14, 2013 9:05 am

Re: Memory read/write

by Mike1313 on Mon May 18, 2020 3:10 am

Hi, thank you for your reply, I will look into it.

Mike1313
 
Posts: 29
Joined: Sat Nov 15, 2014 10:32 am

Please be positive and constructive with your questions and comments.