Experts, I have a 'C' program that contains an array of around 10 unsigned int's. If I initialise it during the declaration, the code never enters main() (I placed a breakpoint on the first instruction inside my main() but it never got hit). unsigned int array[10]={0,0,0,0,0,0,0,0,0,0}; // does not work.
If I remove the initialisation part, it works. Why? MCU = C8051F340 (Silabs) Keil version = C51 COMPILER V7.10 Assembler command line flags: XR GEN DB EP NOMOD51 Compiler command line flags: PW(80) SB LC OT(9,Size) CD DB OE DF(__F340_VER__) Large Linker command line flags: RS(256) PL(68) PW(78) IX
Thanks.
Regards, Ganesh
Running out of stack space?
But a more probable cause: You have a watchdog that is running and not getting kicked in time because the decompress/copy code in the startup file takes too long.
Mr. Westermark, Thank you for taking time to answer.
a) Running out of stack space: I am not too sure if I understand this comment. Are initialised globals placed in stack space?
b) Watchdog: This could possibly be a cause because if I reduce the no. of global variables that I initialise, everything works fine. But then how should I handle this case? Isn't a watch dog timer disabled by default on power up? If not, where should I disable it (obviously it cannot be in my main() because that would execute well after the variables are initialised).
Regards, Ganesh Okade
If the problem is with the watchdog, then you will have to update the assembler startup file.
Have you checked what the datasheet says about the watchdog?
Have you looked at the startup file?
View all questions in Keil forum