Consider a structure with the following data members:
struct Data
{
unsigned int count;
const char *Name;
};
A variable of type struct Data
is created later in the code:
PERSISTENT(struct Data log);
where PERSISTENT()
maps a variable to the battery-backed SRAM memory space.
When Name
is later assigned to in the code (log.Name = "Sensor1";
), where does the character string "Sensor1"
get stored. From what I understand, the pointer Name
is stored in battery-backed SRAM, but does the string it points to get stored in MCU memory? If that is the case, if the MCU is restarted, the string gets lost, but the pointer (stored in battery-backed SRAM) still points to that address which is empty now. Would that be the case?
This code is running on an ARM7 microcontroller (LPC2368 to be specific).
The string literals will be stored in the FLASH memory where the .rodata
segment is located.