Hi,
I have declared 'global variables in below way:
In my main.c file, I have following:
__attribute__((section(".TEST"))) unsigned short global1;
__attribute__((section(".TEST"))) unsigned short global2;
void main(void)
{
unsigned short local1;
unsigned short local2;
local1 = global1;
local2 = global2;
}
In my lnker command file, I have following:
.TEST : {} > MSRAMTEST
MSRAMTEST : ORIGIN = 0x70180000 , LENGTH = 0x40000
With these settings, I see the memory allocation for my global variables as following:
70180000 global1
70180002 global2
However, when my code changes the order of the global variables read, as shown below
void main(void)
{
unsigned short local1;
unsigned short local2;
local2 = global2;
local1 = global1;
}
the addresses in the memory got changed too.
70180002 global1
70180000 global2
Is there any flag which I can set to make sure the address of global variables remain the same, irrespective of the order of usage.
Regards,
Vishwanath Reddy.