Hi,
I'm making a program with the xc864 using the keil application but at some point I started to get the followings errors while I tried to program my micro:
" Content mismatch at address 0000H (Flash=EDH Required=02H) Content mismatch at address 0001H (Flash=B7H Required=0FH) Content mismatch at address 0002H (Flash=DCH Required=D6H) Content mismatch at address 0003H (Flash=7FH Required=78H) ... "
I've proved to comment independents parts of the program and the error disapears. So that I think that the problem is that my code is too huge for the micro.
How can I know what makes my code too huge? There is a way to get more free space for coding?
thanks
Making your program smaller is called optimizing.
On one hand, the compiler has a setting to turn on automatic optimization (for size and/or speed), but it is also a question of being a skilled developer.
Avoid the use of large library functions. Look at your code and see if you can rewrite some parts of the code to be more efficient. Is the code always using the optimum size for all variables?
Turn on generation of a map file, and look in the map file to see how large the program is, and the size of the different modules.
Thanks for the answer,
I've proved to comment the following include = #include <string.h> , and by now it seems it works as you can see the change in the memory map:
new code map= Program Size: data=77.2 xdata=0 const=0 code=3575 old code map= Program Size: data=77.2 xdata=0 const=0 code=4222
But now I've got another problem I used this include in order to compare lists of characters that I've have using the strcmp -->
for example =
if (strcmp(array,"ROK")==0) then ...
can any one tell me how I can compare an array of characters without using this function?
I don't believe that strcmp() is so large as indicated by the size change in the map file. You must have deactivated own code too.
strcmp() is a very small function. For a single compare of short strings, you can possibly do better with explicit character-by-character tests, but I don't expect that to be applicable for you.
Note that it isn't #include <string.h> that affects the size of the binary. It is the number of functions you call. The file string.h is just a menu, giving a list of available functions.
Look through the code and the map file and decide if there are code you can rewrite, or if you have any debug printouts using printf() or similar.
I've removed some printf, but after continuing writing code I've arrived at the same point : Program Size: data=102.1 xdata=0 const=0 code=4493
Looking on the datasheet I've confirmed that the xc864 just have 4k for flash programing, so that I must optmizate the program in order to introduce it but I don't what should I change or rewrite.
I've attached my c code and my map file in case somebody could give me an idea:
" href= "http://docs.google.com/View?id=d8twnwb_546gd8m9t5c">docs.google.com/View --> map file
The whole point of using functions is that the code is not repeated - a function occupies the same amount of code space whether it is called once or 1000 times!
The same applies to library functions; eg, printf: if you remove 999 printf calls, and leave only 1 call, then you will still need to have printf in the code.
Did you actually look at the MAP file, as suggested, to see exactly what is using up all your code space?
"Looking on the datasheet I've confirmed that the xc864 just have 4k for flash programing, so that I must optmizate the program..."
Before "oprimising" the program, have you actually considered whether a 4K part has any chance of being sufficient for your requirements?
At the end of the day, you cannot cram a quart into a pint pot!
View all questions in Keil forum