This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Code banking

Hello Forum,
I recently took over a project, that did not have code banking implemented.
The hardware was designed with code banking in mind, a 128K FLASH is used and the A16 of the FLASH is connected to P1.5 of the 8051. We've have slowly been getting to the point where we need to utilize the upper 64K of the FLASH. I've done some research regarding how to implement code banking, but am having difficulties on what exactly needs to be setup.

This is what I have done so far.
I added L51_BANK.A51 to the project and changed the following:
?B_NBANKS EQU 2
?B_MODE EQU 0
?B_RTX EQU 0
?B_VAR_BANKING EQU 0
P1 DATA 90H
?B_PORT EQU P1
?B_FIRSTBIT EQU 5

In UV2, target options, target tab:
Eanbled code banking.
Bank area start: 0x0000
Bank area end: 0xFFFF

This will give me 2 banks from 0 - 0xFFFF, but what about the comon area? Where will that be placed?

Is it possible to have a 64K common area and a 64K bank0?

TIA,

Andy

Parents
  • This will give me 2 banks from 0 - 0xFFFF, but what about the comon area? Where will that be placed?

    The common area will be copied into both banks. This may sound wasteful, but for your configuration it's not too bad at all. Just try to group common functions together and place the groups in bank 0 or bank 1. Leave as little as possible in the common area to maximize the amount of code space available.

    If you have "common" routines that are frequently called from everywhere in your program, place them in the common area (so that they are called faster than they would be if a bank switch was required).

    You have to gauge the tradeoff between maximum program space (meaning small common area) and maximum performance (meaning few bank switches). Remember that calls to functions in a different bank require a bank switch--and that takes a few extra instructions per function call. Calls to functions in the common area or in the same code bank require no additional overhead, and subsequently, these are fast.

    Create a few simple test cases with one or two functions in the common area, and each code bank to get that warm fuzzy feeling you get when thing work as expected.

    The following knowledgebase article contains a lot of general information regarding code banking: http://www.keil.com/support/docs/158.htm.

    Jon

Reply
  • This will give me 2 banks from 0 - 0xFFFF, but what about the comon area? Where will that be placed?

    The common area will be copied into both banks. This may sound wasteful, but for your configuration it's not too bad at all. Just try to group common functions together and place the groups in bank 0 or bank 1. Leave as little as possible in the common area to maximize the amount of code space available.

    If you have "common" routines that are frequently called from everywhere in your program, place them in the common area (so that they are called faster than they would be if a bank switch was required).

    You have to gauge the tradeoff between maximum program space (meaning small common area) and maximum performance (meaning few bank switches). Remember that calls to functions in a different bank require a bank switch--and that takes a few extra instructions per function call. Calls to functions in the common area or in the same code bank require no additional overhead, and subsequently, these are fast.

    Create a few simple test cases with one or two functions in the common area, and each code bank to get that warm fuzzy feeling you get when thing work as expected.

    The following knowledgebase article contains a lot of general information regarding code banking: http://www.keil.com/support/docs/158.htm.

    Jon

Children