I am using AT89C51. Due to memory overflow I decided to use XDATA variables. Compilation shows no errors, but when I put the HEX files to the controller it will not work. At the stage where the XDATA variables are used, the system collapses and the giving unexpected results. I am using DS1644 time keeping Ram for external storage and for XDATA. What is the problem with my system. Is it need any internal settings or my controller is not suited for this pupose? Please give me a clue. My code is given below:
char xdata sum[12]; char xdata rtc[21];
when sum or rtc are used the system will give unexpected reults. Please help me.
What is wrong with using large model. When I used that compiler shows no error.But hardware not working. I am using AT89C51 controller and external time keeping ram (DS1644)for XDATA. Also uses 27SF010(EEPROM from SST) for code storage. Also I chaned the settings of the compiler as below:
1. in startup.a51:
IDATALEN EQU 100H XDATASTART EQU 0H XDATALEN EQU 2E4FH PDATASTART EQU 0H PDATALEN EQU 100H
2. in project settings: memory model: large variables in xdata off chip xdata memory: 0x0000- 0x113F
3. Device selected:
At89C51
4. Xtal: 16.0
compiler shows 0 errors and 0 warnings. program size:data=30.2 xdata=76 code 15530
Is this need any other settings to use large model ?
Unreadable code. Try to avoid tag characters in your source code. It leads to a lot of problems.
Anyway - it seems like you clear your variable inside a conditional block "if(user==0x55)". That is a broken concept! Never initialize a variable inside a conditional statement, unless your code only accesses the variable within the same conditional statement.
And when you have a problem, make sure that any simplifications you do to the code before posting really do suffer from the problem you want to complain about. How much time do you expect people to spend looking at code that does not contain the original error that you want help with?
I would like to know about nature of XDATA. When I declared variable as XDATA , it onlt resets when power is off. Otherwise it holds the previous value.Is it possible to use XDATA variables as nomal variables after declaration? If it is not possible by simply declaring, how can I use them as normal variables? Is it need any other settings? What will happen if I use large model? When I did so, compilation found to be OK but not working in the hardware. Is this a usual thing?
Ram can not hold nothing. If you can the same function from the same place the RAM location assigned to a variable will be the same address. If nothing over wrote since the last call it will be the same. You can not count on this behavior. Uninitialized variables can contain any number, the are undefined.