Could anyone tell me how to decide commonBank size? and How to check my program size in each bank? I am so confused that how to use codebank. I once changed the size of bank area, but found that my program still can be compiled successfully.
The Common Area should be as large as possible. Your size will depend on your hardware, and emulator. when the common area is too big your program will not fit. The Map file will tell you how much memory is used in each bank.
The 8051 can address only 64K of code. Period. The end. The way that code banking works is that common stuff is stored in the lower part of memory (starting at 0000h). This includes the reset and interrupt vectors, the interrupts, and functions that are called from multiple code banks. This way, the bank doesn't need to be switched in the event of an interrupt or a common function. There is a "partition" address above which is a code bank and below which is the common area. That's what the BANKAREA linker directive sets. The common area is ALWAYS present in memory. The bank area switches based on a bank value (which is used like a group of extra address lines). If the common area is too big, you can't put much stuff in a code bank and so you may need more code banks. If the common area is too small, and common functions are put into banks, performance suffers because a lot of bank switching must be done. Often the size of the common area is based on the design of the target system. For example, you have a 32K ROM for the common area and four 32K code banks from a 256K FLASH device. You can just use a single FLASH or ROM device and specify that the bank area is 0000-FFFF. In this case, the common area is set to the minimum size and is duplicated in each code bank. When you switch banks, the common area is switched, too. But, each bank includes the common area so this is not a problem. Technically, an accurate answer to your question depends mostly on how your hardware is designed. Be sure to look at the following knowledgebase articles: http://www.keil.com/support/docs/158.htm http://www.keil.com/support/docs/1059.htm Jon