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.
int key=0; unsigned long int xdata act1,act2; while(key==0) { act1=0; act2=0; //Here I initialized. void normalRunning() { act1+=act2; } }
What????? are you declaring normalRunning() inside another function? if act1 and act2 are not define inside a function they are global. This means they will hold there value always.
Sorry. That was a mistake when I retyped the code: Actually it was like this:
void normalRunning() { int key=1; unsigned long int xdata act1,act2; act1=0; act2=0; //Here I initialized. while(key!=0) { key=keypress();//This is function to check key //value act1+=act2; //The act2 is calculated from 'key' } }
Here if I called the normalRunning(), the previous value of act1 is still there and is added to new value of act2. What is this?