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

Questions about XBanking

Hi, I've read about XBanking and have some questions.
Assume that I have 128MB of XRAM and I want to separate it to 4 pages, 0-0x7FFF,0x8000-0xFFFF,0x10000-0x17FFF and 0x18000-0x1FFFF.
I use P1.6 and P1.7 for select pages.

- When I declare far variable, how can I choose which page does this variable stored?

- How to config the values of P1.6 and P1.7 for select pages?

I've tried to read all C51.pdf, A51.pdf, XBanking.A51 files and informations in this site also but I can't find detail about this so I decide to ask in this forum.

Thank you very much.

Parents
  • Assume that I have 128MB of XRAM and I want to separate it to 4 pages, 0-0x7FFF,0x8000-0xFFFF,0x10000-0x17FFF and 0x18000-0x1FFFF. I use P1.6 and P1.7 for select pages.

    That really doesn't make sense. You should use A0-A15 for accessing the ram 64K at a time. There is no need to use 2 port pins.

    When you use XBANKING, you define how the compiler accesses "extended" RAM memory. This "extended" memory is only "live" inside the XBANKING routines in XBANKING.A51. Outside those routines, the "extended" RAM is unavailable. This is done because "extended" RAM is typically accessed using MOVX instructions and some kind of chip select/port pins. Under normal conditions, the chip selects are all low and the RAM that is accessed by MOVX is XDATA (0x010000-0x01FFFF). You want to use XDATA BEFORE you resort to using FAR memory because XDATA is much faster (chip selects do not need to be altered).

    The C51 compiler virtualizes "extended" RAM and accesses it using routines you create (in XBANKING.A51).

    From the compiler and linker perspective, you do nothing other than specify that variables are far (to the compiler) and that there is a far RAM address space (to the linker).

    For your example, we can put the 128K of "extended" RAM at the address range 0x020000-0x03FFFF. This is what we specify to the linker. This assumes that we already have 64K of XDATA. If not, it makes more sense to use 64K of your RAM for XDATA and 64K for far memory.

    In XBANKING.A51, you must make changes to the read and write routines so that whenever these routines are called with a "segment" of 02 or 03, your RAM is read and written (whatever that takes). The routines in XBANKING must restore everything that they change (as far as off-chip memory mapping is concerned).

    If 64K of the 128K of RAM can really be mapped as XDATA, then you should do that (XDATA accesses, while slow, are still faster than XBANKING accesses). The additional 64K should be mapped to segment 02 using the XBANKING routines. For the linker, specify that you have 64K of XDATA and 64K of far memory (from 0x020000-0x02FFFF). Remember that XDATA resides from 0x010000-0x01FFFF.

    Hope this helps.

    Jon

Reply
  • Assume that I have 128MB of XRAM and I want to separate it to 4 pages, 0-0x7FFF,0x8000-0xFFFF,0x10000-0x17FFF and 0x18000-0x1FFFF. I use P1.6 and P1.7 for select pages.

    That really doesn't make sense. You should use A0-A15 for accessing the ram 64K at a time. There is no need to use 2 port pins.

    When you use XBANKING, you define how the compiler accesses "extended" RAM memory. This "extended" memory is only "live" inside the XBANKING routines in XBANKING.A51. Outside those routines, the "extended" RAM is unavailable. This is done because "extended" RAM is typically accessed using MOVX instructions and some kind of chip select/port pins. Under normal conditions, the chip selects are all low and the RAM that is accessed by MOVX is XDATA (0x010000-0x01FFFF). You want to use XDATA BEFORE you resort to using FAR memory because XDATA is much faster (chip selects do not need to be altered).

    The C51 compiler virtualizes "extended" RAM and accesses it using routines you create (in XBANKING.A51).

    From the compiler and linker perspective, you do nothing other than specify that variables are far (to the compiler) and that there is a far RAM address space (to the linker).

    For your example, we can put the 128K of "extended" RAM at the address range 0x020000-0x03FFFF. This is what we specify to the linker. This assumes that we already have 64K of XDATA. If not, it makes more sense to use 64K of your RAM for XDATA and 64K for far memory.

    In XBANKING.A51, you must make changes to the read and write routines so that whenever these routines are called with a "segment" of 02 or 03, your RAM is read and written (whatever that takes). The routines in XBANKING must restore everything that they change (as far as off-chip memory mapping is concerned).

    If 64K of the 128K of RAM can really be mapped as XDATA, then you should do that (XDATA accesses, while slow, are still faster than XBANKING accesses). The additional 64K should be mapped to segment 02 using the XBANKING routines. For the linker, specify that you have 64K of XDATA and 64K of far memory (from 0x020000-0x02FFFF). Remember that XDATA resides from 0x010000-0x01FFFF.

    Hope this helps.

    Jon

Children