Storing Variables in a Fixed Location in Memory

Greetings,

I want to store the result of my project (an integer) in a fixed location in memory. I have discovered the uctypes library but cannot understand it as of now, since im unfamiliar with C. I have no memory map of my device (OpenMV Cam H7) so dont really know where to store my integer either, without corrupting my project.

Is there a simple and safe method to ensure that my integer will be stored in a specific memory adress?

Yes, use the “stm” module.

import stm

stm.mem32[0xCCCCCCCC] = 0xAAAAAAAA

This lets you write anything to any address. Also, there are constants defined for STM register addresses.

You can also read from any address. However, there is no projection if you write/read for the wrong address.

Thak you for your fast reply!

I cannot seem to find any documentation about the stm module but it does seem to work on the OpenMV Cam when I import the module. Can you please post a link to the stm documentation?

Kind regards

It doesn’t really have documentation. MicroPython didn’t document it.

You just do:

stm.mem32[address] = value

Or

value = stm.mem32[address]