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

Best Reference for 8051 Using Extended Code Memory

Could someone point me to the best reference for using code flash greater than 64KB? I am working on a project that uses the SiLabs C8051F121 that has 128KB code flash. I am about 10K away from 64KB so I need to figure out how to use the upper 64KB and at the moment am having mixed results figuring things out. In particular I have two problems that I cannot figure out.

1. I want to place a CRC in my code so that I can determine if there has been any data corruption in the flash. I want to place the CRC at physical address 0x1EFFE (I am setting aside 0x1F000 - 0x1FFFF). I can modify the HEX file and place the CRC at the desired address but I cannot figure out how to get the compiler/linker to do it. I created an A51 that has the following code in it:

        CSEG    AT      0x1EFFE ;CRC_ADDR
                DW      0xABCD ;CRC

                END

Without activating Code Banking this places the CRC at 0xEFFE. If I turn code banking on and specify that this A51 file be placed in Bank #3 then the CRC gets placed at 0x1EFFE and 0xEFFE. Why does that happen? (In uVision under Configure Flash Tools, I select the Target Tab and select Code Banking, Banks = 4 and for Bank Area: Start=0x8000 and End=0xFFFF). However, looking in the HEX file I cannot find the duplicate CRC.

2. The second problem appears related to #1 in that if I specify any files in a Bank other than Common I will get a portion of my code duplicated in both the lower 64KB and the upper 64KB. These duplications are in the HEX file. Again, I do not understand why code is being duplicated.

My understanding is that when code banking is instituted, the common bank 0x0 thru 0x7FFF is always available at this address range and the rest of the code is "paged in" via the code banks using address range 0x8000 thru 0xFFFF but actually reside in physical addresses as shown here:

Bank 1: 0x8000 thru 0xFFFF
Bank 2: 0x10000 thru 0x17FFF
Bank 3: 0x18000 thru 0x1FFFF (with the range 0x1FC00 thru 0x1FFFF reserved on the SiLabs device)

I am using the LX51 linker and the L51_BANK.A51 file but just do not understand why the above things are occurring. If anyone could provide me an explanation or a pointer to documentation that might better explain this I would appreciate it. I have combed thru the Keil and SiLabs sites and have some App notes and other resources but nothing so far, in my opinion, explains code banking very well so that I can understand the above behaviors.