Hi, I have some global variables declared in a module and initilized to some values. When I start debugging I've noticed that those globals have random values. I've checked the "Use Memory Layout from Target Dialog" in linker options.
/* Globals */ int counter = 0x550; int slack = 0; int timeout = 0; static uint32_t button = (uint32_t)0x00000000; static int init_val = 0; static uint16_t buffer[BUFFER_SIZE]; volatile uint32_t num = 0U;
Thanks for your support.
IDE-Version: µVision V5.10.0.2 Copyright (C) 2014 ARM Ltd and ARM Germany GmbH. All rights reserved.
Tool Version Numbers: Toolchain: MDK-ARM Professional Version: 5.10.0.0 Toolchain Path: C:\Keil_v5\ARM\ARMCC\bin\ C Compiler: Armcc.Exe V5.04.0.49 Assembler: Armasm.Exe V5.04.0.49 Linker/Locator: ArmLink.Exe V5.04.0.49 Librarian: ArmAr.Exe V5.04.0.49 Hex Converter: FromElf.Exe V5.04.0.49 CPU DLL: SARMCM3.DLL V5.10.0.0 Dialog DLL: DCM.DLL V1.10.0.0 Target DLL: STLink\ST-LINKIII-KEIL_SWO.dll Dialog DLL: TCM.DLL V1.14.1.0
You don't mention what processor you use. And you don't mention if you have been playing with the startup file.
1) If using external memory, then the startup file must initialize the memory controller so this external memory can be reached.
2) The startup file must call the normal CRTL initialization code, so that initialized variables gets these values, and the rest of the memory gets zeroed.
Sorry, I'm using the STM32F407 discovery board. I didn't modify the startup file which is \STM32F4-Discovery_FW_V1.1.0\Libraries\CMSIS\ST\STM32F4xx\Source\Templates\arm\startup_stm32f4xx.s
Have you made sure that you haven't accidentally ticked 'NoInit' in the target dialog?
Yes absolutely
I suggest that you contact our support (support.intl@keil.com) with this question. Sending your project may help here.