hi am using 89c55 and wrote a code in c which acquires data from a serial device performs calculations and the gives an alarm when an abnormality is detected. when i compiled i got as Program Size: data=9.0 xdata=7569 code=4140. i used large memory model.it works well when i checked with keil simulator but when i burnt into my uc i don see any output. iam new to uc's should i add any eeproms before burning?? please help me out. thanks in advance.
regards, deepthi
Do you Have 8K of external RAM?
no i don have external ram but the chip has 20 K Flash Memory, 256 Bytes On-chip RAM,hex file was 14k in size which i have burnt into uc..
In your 1st post, you said:
"when i compiled i got as Program Size: data=9.0 xdata=7569 code=4140."
So your program requires nearly 8K of XDATA space - how is that provided in your system...?
i used large memory model in target settings in keil simulator because my code is not compiling when i ve set small memory model.. should i use any external ram or eeprom to my chip before burning a code into that..
"should i use any external ram"
Well, if your program uses 8K of XDATA, and there isn't 8K of RAM available inside the chip, where else do you think it is going to come from?!
It's just like running a program that requires 1G of memory on a PC that has only 640K, isn't it...?!
thanks andy for that response.ur right i should have had 8k external ram, and iam sure u might get irritated with my silly questions and mistakes,but am a starter and need some help from experts like u... can u just tell me if there is any way to reduce the xdata size.i mean how can i change the variables or code to fit in available flash memory. and please tell me what does this code and data indicate in program size after compiling..
The flash memory is for code - the instructions telling the processor what to do.
The data memory (RAM) is for variables, i.e. letting the program keeping track of what it is doing.
Your program needs a lot of RAM compared to what your processor supports. It is unlikely that the program can be shrinked to fit.
thanks for that information per..now i am clear why i have to have an external ram..please help me in using this ram, as how to interface to my uc.. and how do i burn a code into that..and should i include any extra code to access variables from that ram..
now i am clear why i have to have an external ram..
That's not all that clear yet.
Looking at your programs memory usage, it looks like your have a fairly small program (~4kB) that requires huge amounts (for a '51 program) of space (~8kB) for its variables.
You should look at what's actually in those ~8kB. Are there constants (lookup tables, strings, etc) that could be moved to code memory instead? Are there statically allocated variables that don't need to be static? Does the program use memory overlaying?
i don know what is memory overlaying..please explain me what that is. and as u said my code size is 4kb only, these are the variables am using.
float in=1,out[1000],th1=0,th2=0,spkf=0.0075,npkf=0; char squr[1000],low=0,high=0,der=0,mwi=0; float hr=0,rr=0,rr_r=0,out1=0; int z=0,m=0; unsigned char e=0,h=0,r=0,v=0,i=0,q=0,b=0,d=0,l=0; char k[1066],dat=0,y;<pre/>
i don know what is memory overlaying..please explain me what that is.
The exact details are described in the C51 compiler manual.
It is a way to save memory used for variables by figuring out which variables do not exist at the same time, and making those variables use the same space in memory.
Example:
void some_function_1(void) { char a; ... } void some_function_2(void) { char b; ... } void some_function_3(void) { some_function_1(); some_function_2(); }
a and b do not exist simultaneously, and hence they can share the same location in memory.
these are the variables am using.
You should check whether you really require those huge arrays, namely:
float out[1000]; char squr[1000]; char k[1066];
That's about 6 kB right there.
i need those three huge arrays all through my code so i cant avoid them, will the size gets reduced if i declare those arrays dynamically instead of static declaration and coming to this memory overlaying, thanks for giving an example.ill modify my code acc to this and will get back to u. thanks for responding all of u
Dynamic or static doesn't matter.
What matter is how much variables you need at the same time. If you need these arrays at the same time, then you need to have enough RAM for storing them.
Of an array stores constant - unchanging - data, then you can move the array into the flash, i.e. among the code. If the array contains values that are seldom changed, then you may use EEPROM or similar for storing the data. But whatever you do, you will need enough memory - of the correct type - for storing the arrays, or you will have to figure out a way to reduce the size of the arrays.
the data of these arrays is not constant but changes frequently so i think i have to go for EEPROM or external RAM.. but i don know how to interface that and use it while burning code into that..please help me out in this regard and it would be very helpful if any circuit diagram or code is given.. thanks in advance
You do _not_ burn code into the RAM. The RAM is for the variables. And as you have noted - the simulator can work with your program. So start by googling for how to connect RAM to your processor.
You do not want to use EEPROM fo frequencly changing data. If it is important that the data survives a power loss, then you should look for other alternatives, such as battery-backed RAM or ferro-electric memories. But every memory cell in EEPROM can only handle a limited number of write cycles before wearing out. This can be mitigated by having a very large EEPROM and do wear-leveling, where you use many memory cells to share the number of writes. But wear-leveling is a complex solution that should be avoided if possible.