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.
Dear all, My project using code banking. I have a table that store in CODE memory(BANK1(?CO?MENUROOT(0x2000))). And my program in many Banks(Bank1, Bank2, Bank3......) reference to this table. But only program in bank1 can get the correct table value. Because a lot of reasons, I have to seperate these programs into different banks. And I don't want to create many copy of this table in defferent name to put them in each bank. How can I solve this problem? Thank you. Ovid.
Note that this isn't really a C51 limitation, but a limitation from the design of code banking. Code bank 1 can be switched in and out of the address space of the processor. You've declared data to live in code bank 1. That data gets switched in and out of the address space along with bank 1. Only when code bank 1 is switched in can you see that data. That's generally only when code in bank 1 is executing. And banks 2+ all replace bank 1 when they are switched in (in the usual 32K + N * 32K banking scheme). No code other than that in bank 1 can be sure to see that data in bank 1, and code in banks 2+ can be certain that it's not visible. The common bank is always swapped in, which is why its the default location for constant data. You might also locate the constants in xdata, and copy them from code to xdata via some init function (that lives in bank 1).
"You might also locate the constants in xdata, and copy them from code to xdata via some init function (that lives in bank 1)." Or, if your memory architecture permits, have some ROM mapped into XDATA space...