8051 Keil How to support code size larger than 64KB projects

Source: Internet
Author: User

As the functionality of the project continues to increase, the program code size is constantly rising, and when more than 64KB, consider introducing the bank into the system.

Before you tell me how to add a bank function to an existing project, let's talk about the background of its existence.

8051 is based on the Harvard architecture. Code memory is 16-bit addressing, and data memory is 8-bit addressing. This separate addressing feature is suitable for comparison of fixed, and relatively small curing procedures, and relatively strong stability, such as data access does not mistakenly refer to the code directive. Of course, the drawbacks of this architecture are also obvious, namely, lack of flexibility, such as the inability to effectively use memory resources.

Since it is 16-bit addressing, it means that only 64KB of program code can be supported. If the project code exceeds 64KB, it is necessary to introduce multiple banks to support it. A bank can support 32KB, the 4 bank can support 128KB, 8 bank support 256KB, and so on ... In general, an MCU can support code size above 2MB.

Now let's talk about how to introduce the bank into existing projects.

1) Right-click the project name in the left lane of the Keil IDE and click "Add Group ..." To add sub group, take four banks as an example, to ensure that there are 4 sub groups under the project name. Of course, if you already have groups, you don't have to add any more. In general, we bank0 also called Common, its address range is 0x0000~0x7fff, the other bank#n range is set to 0X8000~0XFFFF. As shown in.


2) Next is the point, because Keil will not specify whether they are bank0 or bank1,2,3 according to these groups names ... Besides, developers can also change the name of the bank into aliases, such as application, in the IDE. So you need to right-click the groups to click Opitons->properties-> to specify the bank number.

3) Right-click the project name, then options-> check "code Banking"->select "4", then bank area is set to start:0x8000, END:0XFFFF

4) Finally, in order to compile, you need to add the L51_bank.a51 file into the project

5) Some details to note is that if you tick extended LX51 Linker instead of BL51, in order to compile the link, then you need to options->output HEX-80 to HEX-386, and check the merge 32K Hexfile. In order to improve the efficiency of the program execution, avoid unnecessary bank switchover, try to put the frequently called code into the common bank.

8051 Keil How to support code size larger than 64KB projects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.