We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, I am working on a project using the 8051. I am almost on my completion of the project. But my code size has cross the 64k limit. I have heard that by using paging technique it is possible to access more than 64K code. But i have no idea how to implement paging in 8051.Can any one help me for the same. Thanks in anticipation. Viral.
I would like to add just a couple of comments. The 80C51 is an 8bit device. The most efficient data type for code size will be the unsigned char. The next most efficient is the unsigned int and then to the signed data types. Try at all places possible to use unsigned. Next, get rid of the printf or scanf if you use them. Use puts and do you own formatting. Last but not least, get rid on float values if possible. Most of the time simple fixed point processing will calculate all the values you need. Of course Andy answered you initial question about code banking. Brad
"Next, get rid of the printf or scanf if you use them. Use puts and do you own formatting." Of course, all generalisations are bad! ;-) A single printf can cause quite a large hit on code size (it can use up most of the 2K size limit of the free eval version), but if you do a lot of formatting throughout a large application it becomes a lot less significant. You might want to search this forum for Graham Cole's user_printf, which was a streamlined version without the more esoteric formatting options.
Hi, Thanks every one for your valuable feedback. I have try using different optimising level but my code started behaving eraticly. It may be because my code is very time critical. I will try some of your other suggestion and hope it works. Regards, Viral.
If raising optimization levels makes your code behave erratically, that's almost certainly not just because the program is time-critical. It's because either there's a bug in the optimizer, a bug in your code, or bad design of the code. Bugs in your code would usually be lack of "volatile" qualifiers on some variables shared between main and interrupt routines. Design errors would be things like expecting that you can generate fixed-time delays by empty loops coded in C, which the optimizer may justifiably delete completely.
"I have try using different optimising level but my code started behaving eraticly." What levels have you tried? At what level do the problems appear? I agree that this is probably due to flaws in your code that only become evident at higher optimisations; therefore, you should debug these problems!
There were some compiler/linker problems with high levels of optimisation. See: http://www.keil.com/forum/docs/thread2094.asp. I belive that these have been fixed in the very latest versions of the tools, so make sure that you are up-to-date.