This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Program with initialised global variables does not run

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

Parents
  • But turning off the watchdog is normally not something you want to do. In real life, the watchdog is something you should be ready to pay extra for, because you really do want your hardware to be restarted in case something goes wrong.

    Your code may be ok, but if they mount your hardware besides a huge contactor to turn on the lights for a sports stadium, your hardware can go into a spin when the contactor gets activated. It isn't always so easy to test that the electronics can handle big peaks on the supply or signal wires or can survive strong EMI, unless you have very special test equipment or sends it to a laboratory for testing. The watchdog is there as a final resource to _maybe_ solve the problem if something goes wrong. I write _maybe_ because a watchdog can't solve a latchup problem. For a latchup, the affected chip must be without power for a significant amount of time - it can take days without power for the latchup to release.

Reply
  • But turning off the watchdog is normally not something you want to do. In real life, the watchdog is something you should be ready to pay extra for, because you really do want your hardware to be restarted in case something goes wrong.

    Your code may be ok, but if they mount your hardware besides a huge contactor to turn on the lights for a sports stadium, your hardware can go into a spin when the contactor gets activated. It isn't always so easy to test that the electronics can handle big peaks on the supply or signal wires or can survive strong EMI, unless you have very special test equipment or sends it to a laboratory for testing. The watchdog is there as a final resource to _maybe_ solve the problem if something goes wrong. I write _maybe_ because a watchdog can't solve a latchup problem. For a latchup, the affected chip must be without power for a significant amount of time - it can take days without power for the latchup to release.

Children