Topic : Why won’t my global variables get initialized?

Forum : ARM

Original Post
Post Information Post
April 27, 2009 - 4:31pm
Guest

Why won’t my global variables get initialized?

If I load the QuickStart_STM32 project and add the following global variables above main:

u8 a = 10,b = 56;

char name[20] = "Hello";

And when I debug the program the variables are not initialized.

I use boot mode RAM.

Replies
Post Information Post
+1
0
-1
April 28, 2009 - 3:08pm
Guest

Hi

I guess it might be an optimization issue. I mean if the code is optimized and the variable are not used you won't see the value you expect.

May be try the code below to really check that variable are initialized or not.

u8 a = 10,b = 56;

char name[20] = "Hello";

int main(void)
{

if (a)
printf ("Yes");
else printf ("No");
}

Regards,
Matloub