How do we initialize the XDATA memory with dummy data (e.g. 0xDEADBEEF)?
By default all the memory is initialized to 0x00 during debugging (in the IDE). When you burn your firmware on the controller, the memory holds random values. To be able to detect uninitialized variables, I'd like to initialize the XDATA memory space to a predefined (non-zero) value.
Note that I don't want to overwrite the global static variables (i.e. those that are rightly initialized to a value). E.g. static unsigned char foo = 0x00.
I guess what I want must be done in INIT.A51, prior to initializing the static variables. Any idea how? Samples welcomed!
Hi guys
Thanks for the tip. Indeed, the snippet of code below seems to be doing what you indicated:
IF XDATALEN <> 0 MOV DPTR,#XDATASTART MOV R7,#LOW (XDATALEN) IF (LOW (XDATALEN)) <> 0 MOV R6,#(HIGH (XDATALEN)) +1 ELSE MOV R6,#HIGH (XDATALEN) ENDIF CLR A XDATALOOP: MOVX @DPTR,A INC DPTR DJNZ R7,XDATALOOP DJNZ R6,XDATALOOP
In my case, XDATALEN was set to zero.
Please read the instructions on how to post source code: www.danlhenry.com/.../keil_code.png
Note that TABs don't work (well) - use spaces instead,
and don't forget to check it in the 'Preview'...