Placing variables in dedicated part of memory.
Hi
I'm using a STM32L433 in a battery application, and running in Stop mode. I want to keep some variables in RAM2 so their values are not lost when the processor is woken up.
I managed to get it working as follows. I created a block in the linker file called ".Permanent_buffer ", then initialised a block of memory to fit in it, see below at bottom.
I will have a few variables working this way, and wondering if there is a way I can assign the start all variables in RAM2, for example ( I havent a clue how to do this, just to show what I mean):
#define .Permanent_buffer
int PermA=1; //will keep value on STOP
long PermB=2; //will keep value on STOP
#endif
int TempA=3; //will loose value on STOP
long TempB=4; //will loose value on STOP
This way it would save me adding __attribute__((section(".Permanent_buffer"))) one each variables. Is there a way to do this?
Many thanks
Scott
Code I have working.......
typedef struct{
long sig;
long date;
long time;
short int hum;
short int temp;
}Results;
char PermanentBuff[sizeof(Results)*500] __attribute__((section(".Permanent_buffer")));
Results *ResPtr=(Results *)&PermanentBuff[0];
Linker file:
.Permanent_buffer :
{
KEEP(*(.Permanent_buffer))
} >RAM2