cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 C Global Variables do not have their initialized values

Nabs
Associate II

Was working on an EVAL board stm32G474RE which has FLASH of 512K and RAM of 128K. Everything was working fine on the EVAL board. Now we received the actual hardware which is a stm32g474CBU. Very similar to the EVAL board but the FLASH 128K and RAM of 128K.

Very few changes were required for the new micro like the linker file. But started noticing a strange behavior where some of the global variables that were initialized in the code, did not have their values. As in the moment the program is downloaded and I hit the breakpoint in the main function, the values for the global variables are not there and just 0xFFs.

It appears that the values of the global variables were not even copied from the flash to the .data section of the memory.

text      data    bss       dec      hex

59416 11528  26768   97712 17db0

Any ideas. As I mentioned before, the code works perfectly on the EVAL board which has pretty much the same micro.

10 REPLIES 10
Nabs
Associate II

You were right