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

Array intialization

I'm seeing some strange behavior when initializing arrays. I'm using the following code to intialize a 256 element array to zeros:

xdata char myarray[256] = {0}

The code seems to hang when I run this using my debugging hardware. If I run this with the simulator it seems to work fine. If I reduce the number of elements to 50 it works OK, but increase it to 60 and I get it to hang again. Has anyone seen this before? Is it a hardware issue vs compiler/assembler issue?

Parents
  • Have you verified the map file against the actual fysical memory you have? Is the xdata internal or external RAM? If external - have you configured the chip to turn on external addressing?

    Another thing - I don't know exactly how smart the C51 compiler/linker is, but your variables will be zero-initialized even if you don't assign zero to them. Without an assign, you will be sure that the startup code will not have to decompress and assign any information stored in flash but will just zero-fill the memory.

Reply
  • Have you verified the map file against the actual fysical memory you have? Is the xdata internal or external RAM? If external - have you configured the chip to turn on external addressing?

    Another thing - I don't know exactly how smart the C51 compiler/linker is, but your variables will be zero-initialized even if you don't assign zero to them. Without an assign, you will be sure that the startup code will not have to decompress and assign any information stored in flash but will just zero-fill the memory.

Children
No data