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

24 bit addressing required in keil for DP 8051

Hi,

How to use 24 bit addressing in keil for DP 8051.

We want it in C language.

  • See the sections of manual that discuss bank switching.

    To summarize, you need to include an extra file in your project, either XBANKING.A51 (for data banking only) or L51_BANK.A51 (which can do both code and data banking).

    You must customize the code in these files to write the extra byte of DPTR. (Many 8051 variants, for example, have an extra SFR often called DPX that holds the upper 8 bits of a 24-bit DPTR address.) The example code has support for a few common address extension schemes, so you can activate that code with defining a few values.

    Once you have this code correct, you simply tell the compiler that you have banking enabled. The far keyword allows you to define 24-bit pointers and declare variables in "xdata" beyond the first 64KB.

  • can we declare a 24 bit address location as a register, similarly as we do in 8 bit address registers.

    Ex. #define REG8 (*((volatile unsigned long int xdata *)(x))) // were REG8 is an 8 bit register and x is the 24 bit address

    will this work when x is a 24bit adddress loaction?

  • What do you mean by "REG8 is an 8 bit register"?

    REG8 is the name of a define - it has no actual meaning in itself.

    The value returned when using the REG8 macro is an unsigned long.

  • #define REG8 (*((volatile unsigned long int xdata *)(x))

    If in this case I take data type as char instead of long int it will be of 8 bit.

    i.e.#define REG8 (*((volatile unsigned data xdata *)(x))

    In previous case it is taken as long int it returns the 32bit value.

    This ia an example.

  • If you intend to access 8 bits of unsigned data, you should write "unsigned char". If you just write "unsigned", it will return an unsigned integer which is 16 bits.

    For size of data types, see:
    http://www.keil.com/support/man/docs/c51/c51_ap_datastorage.htm

    And once more, do be careful about naming conventions. Your original definition of REG8 returned unisgned long, which for the C51 compiler is 32 bits.

  • If you have hardware memory-mapped into the far data space, then yes, a declaration similar to this will work. (The comments already made about data types are well put.)

    Your hardware external to the 8051 will of course have to decode the 24-bit address bus and select whatever device it is that has these registers. The details will be in the data sheet for your particular 8051 variant.