Overlaying Variables in RAM | Cypress Semiconductor
Support & Community
Overlaying Variables in RAM
Can I overlay variables in RAM?
Yes, you can. These are the steps to follow:
1. Create the variables to be overlaid in assembly and declare the area as Ovr.
area OverlayD (RAM, REL, OVR)
OverlayD is the name of the area.
2. Create a file in your project folder called custom.lkp making sure you do not have .txt also appended to the file name. Add the following line: -bOverlayD:_2.
This says that the area OverlayD starts from RAM location 2. Therefore, the linker will put the variables in the area OverlayD from location 2 even if you have other variables on the same location.
You cannot use a variable in the custom.lkp file such as: -bOverlayD:_variableX . This will not place the area OverlayD starting from location pointed to by variableX. It will not work as well as it will not give an error. The stack pointer starts from bss_end location. And if your OverlayD area is after bss_end, you want to change the stack pointer location. This can be changed in the boot.tpl file - Start routine.