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

Problem initializing global variables

Hello!

I'm using a AT89c51RC Controller for my application.

When I define global variables with an initial value,
they are not always initialized correctly.

Example:

signed int test=3;

If I place the variable on the beginning of the xdata
memory space, then they are initialized correctly. But if
I place the variable at the back of xdata, they have wrong
values like -16235.

I have deleted or commented out all loops in my programm,
so there cannot be a memory overflow, that is produced be me.

If I initialize the variables later within my program manually,
everything works correctly -> so the error must occur before the program
starts.

I also checked out the amount of xdata that is used by my
program, but its far from being full.

Is it possible, that there is an error in the startup.a51 or init.a51 files?

I use no reentrant functions, so I disabled the XBPSTACK but
that changed nothing ...

Maybe someone can help me or give me a hint

Josef

Parents
  • "On start of my C-program i set the AUXR Register to value 0x0c to change the size of xdata from 256 bytes to 1024 bytes. After this command variables in xdata with an address greater that 0x100 have wrong initialization values."

    I'd have thought that was entirely to be expected?

Reply
  • "On start of my C-program i set the AUXR Register to value 0x0c to change the size of xdata from 256 bytes to 1024 bytes. After this command variables in xdata with an address greater that 0x100 have wrong initialization values."

    I'd have thought that was entirely to be expected?

Children
No data