Page 1 of 1

Read/Write uC internal memory

Posted: Mon Oct 25, 2021 12:55 pm
by Andrew1234
I want to write a value to the internal non-volatile memory of the uC, so it can be retrieved after a subsequent startup. I don't see a library function to do this in the quick reference guide for the pyboard.

For example, suppose I read a value from the ADC, and I use that value to set a volume control register in an external device using the I2C bus. I would like to recall that volume control setting after reset. I'm looking for a function to allow me to write the value to internal memory, so I can later read it back, to accomplish this.

Regards
Andy

Re: Read/Write uC internal memory

Posted: Mon Oct 25, 2021 2:34 pm
by Roberthh
AFAIK, such a function exists only in the form of writing the data to a file.

Re: Read/Write uC internal memory

Posted: Mon Oct 25, 2021 4:24 pm
by Andrew1234
Thanks very much. I'll look into that idea further. Also my example doesn't make too much sense, since I can just read the ADC again on power-up. But the general question remains (if for example I used a pair of GPIOs to implement up-down buttons, and I want to recall the final volume setting). Another thought is I could have an external memory and read/write to it via I2C or SPI. But my preference would be to use the uC memory to avoid the extra IC.

Regards
Andy

Re: Read/Write uC internal memory

Posted: Mon Oct 25, 2021 7:12 pm
by dhylands
You didn't mention which board you're using.

There are functions available on some ports to make the RTC non-volatile memory accessible.

You'll need to add a backup battery in order for the memory to be retained across power cycles.

For the pyboard, see this post: viewtopic.php?f=6&t=7064&p=40196#p40196

Some ports have RTC.memory() (ESP8266 and ESP32) viewtopic.php?f=2&t=7013