Hi All,
I am using DS89C450 MCU and writing my C code using uVision 4 compiler. In my DS89, I had a SRAM of 1kB and I would like to declare a 500 variable of unsigned char therefore I use
unsigned char xdata IR[500];
When I compiler with uVision 4, it show no error and therefore I burn the Hex code into my MCU. However, when I write and then read the IR[500], it give incorrect value
I therefore proceed to use debugger to troubleshoot my code and everything works fine in the debugger. My code does not have any problem.
Therefore I suspect uVision 4 had assign the IR[500] to non SRAM location and therefore the value is actually not written and read.
I would like to know how can I make sure uVision4 assign the SRAM location correctly and is there any setting I need to set before compiling?
Pls help. Thanks a lot
Hi Erik,
I dont understand what you mean by startup.a51? I set my bit in the main loop. Do you mean it will not work this way?
Where should I set the bit then? The register is not bit assessable. So I have to read the whole register and write to only bit 0.
But if you set the bit in main() - don't you then wonder how come global variables magically gets their initial values before you reach main()?
The processor performs quite a lot of work before the execution reaches main(), and some of that work requires that the memory used for storing your global variables is already accessible.
http://www.keil.com/support/man/docs/c51/c51_ap_customfiles.htm
And, again: http://www.keil.com/books/8051books.asp
some people, I shall not mention who, had made this huge '51 project and asked me for help.
Early on I realized that main() started something like this
void main(void) { indexer =0; offset = 0; temp = 0; ...... ...... ......
When I asked "why" the reply was "this compiler (Keil) does not initialize variables". well guess what
Erik