what's the affect of XDATA space memory overlap? I have 128 Kbytes of external ram so I use 17 Address buses and switch between 2 pages of ram by A17. I use _at_ for some data that I want to fix at both pages so there are some space overlap(variables have same address but not the same page when run) and keil warn me about this. The problem is my code doesn't work although my last version that doesn't use _at_ works well. Can I ignore this warning? How should I do? I don't know the problems are from my code or from this warning. I'm checking but can't find something wrong. Thank you very much.
Have you configured the compiler to know that you have more XDATA? See the manual, and XBANKING.A51. The tools can automatically handle the bank switching for you. Thus configured, you would assign the variables in different pages different "far" addresses rather than the same one.
If you don't want to use Keil's XBANKING support, but just do your own "manual" bank switching by "manually" tweaking a port pin, could you use a union to represent the overlapping areas?
Thank you for your answers. Do you mean I cannot ignore this warning? Do I have to clear this warning before? I'll try to do this.
hi, I have 128 Kbytes of external ram so I use 17 Address buses and switch between 2 pages of ram by A17. 1)You are right, to access 128kb you need with 17 address lines: A0...A16. So I think you meant A16, not A17, as bank switch. 2)Follow Drew Davis suggestion and then create own XBANKING.A51 based on original one; this is correct (and convenient!) way to fix your troubles only. 2)Andrew Neil: it is not always easy to use union for such purposes. For example, next definitions may be translated to union easy:
unsigned char xdata var_a1 _at_ 0x0010; // bank 1 unsigned char xdata var_b1 _at_ 0x0010; // bank 2
unsigned char xdata var_a1[100] _at_ 0x0000; // bank 1 unsigned int xdata var_b1 _at_ 0x0064; unsigned char xdata var_a2 _at_ 0x000F; // bank 2 unsigned long xdata var_b2[32] _at_ 0x0010;
I have some questions. 1. Can I use Bank Switching even though the 8051 controller doesn't support bank switching? 2. refer to this page => http://www.keil.com/support/docs/2103.htm but I don't understand some steps in that page. - If I use P1.4 to control bank switch so I must set ?C?XPAGE1SFR = 0x94? - I design my memory like this 0x0000 - 0x0FFF => unbanked xdata 0x1000 - 0xFFFF => bank0 (1)0x0000 - (1)0xFFFF => bank1 Do I have to set User classes to HDATA (X:0x1000-X:0xFFFF, X:0x10000-X:0x1FFFF),right? 3. In that page said, "To allocate variables in these spaces, simply declare them as far memory types. For example: int far array[100];". This mean if I declare far variables so it is at page1, and it is at page0 if I not use "far"? Is the above setting for 2 banks memory? How can I setup for 3 or more banks memory? I try to read manual and search by google but I can't find any good example except that page but I think it's not clear for me. Thank you very much.
I forgot to say that I've tried to use union and it works well. But it still has some problems about address of unbanked variables. So I would like to use bank switching, maybe I'll like it.