# How to store a const string at a memory location in Microcontroller?

I have two questions

1.   #define PORTBASE 0x40000000
unsigned int volatile * const port = (unsigned int *) PORTBASE;
*port = value; //write to port
value = *port; // read from port


Can I use the above method to store a value at desired memory location and access it?

2. How can I store, for example, a software version information string(V1.2AG4ML) in the same way at a location?

SPC5 32-bit controller is used.

Regards, Joe

• How you do this typically depends on the compiler, but no your example code would not generally work for this at all. In some more purely Harvard architectures like an AVR data access to flash memory may also require special keywords to trigger generation of special instructions. – Chris Stratton Jul 9 '18 at 5:36

1. You can only use that method to write to an area to you actually can write to. Since all you're doing it writing value to the address given in port.
In any case, it usually starts with an const char *version = "V1.2AG4ML" in a separate object (file), that you will put in a region manually via the linker script.