Hi all,
I've been using Keil MDK-ARM 4.13 version and LPC2378. Can you please say whether there is a reference document of Keil (online or doc) included how to define variables and use for a battery RAM area (or NVRAM)? I've seen a lot forum threads but Keil should be have an online help document that includes such things. If so, can you please give me that link?
Thanks in advance a lot for your helps,
Best regards,
Yasemin
Easiest is just to a pointer that you initialize to the start of the 2kB battery-backed RAM. Let the pointer point to a struct with your variables. The startup file will not zero-initialize this memory region as long as your project doesn't specify this RAM region.
Just remember that your code must use some form of checksum, CRC or similar to figure out if you have valid contents in the RAM since a previous run, or if this is a first start (or the battery voltage have dropped too low for retention).
Note that the RAM doesn't lose all contents instantly. If the supply voltage is too low, you may first get just a few bits that toggles making most of the variables look like they are valid even when not.
Locating variables within the system's memory map is part of the Linker's job - so you need to study the Linker manual for this.
You will need to use a Scatter File (qv)