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

P89C51RD2Hxx: How to configure XRAM to 32K

Hi,

Would anyone please advise me the steps as how to configure the settings [startup.a51]?? so that program can access or allocate XDATA varibales in 32K memory size??

Thanking you in advance.

Cheers,
Simon

  • Unless you have some strange derivative you don't need to modify startup.a51. Just make sure you've specified the correct size and start address for your xdata memory in Target->Options then declare variables with the xdata keyword:

    int xdata foo;

    A good "reading of the manual" wouldn't do any harm either.

    Stefan

  • Thanks for your reply.

    My test program works with internal ERAM 768 bytes, like XRAM. When I install 32K RAM board, and with xdata variable declared to a larger size, it is not working.

    I have studied the data sheet and it says that AUXR register is required to set to 0x03 to enable
    1. ALE active with MOVX or MOVC instruction
    [AO=1]
    2. to enable external data memory access
    [EXTRAM=1]

    As there are a number of things I have to check, such as the memory board...etc., I would appreciate very much of your advice on

    whether the AURX=0x03 is set/ declared in the main program or in the startup.a51 file so that I can focus on trouble shooting other possibilites.

    Thank you very much for your time and advice.

    Simon

  • I didn't notice that you had specified the derivative in the subject line. Unfortunately I don't know anything about this derivative, maybe someone else can answer your question.

    It's a good idea to include all the pertinent information in the body of the message.

    Stefan

  • Hi Stefan,

    Thanks for your reply. I'll work on it and see how it will come out.

    Your advice is appreciated.

    Simon

  • I use that chip a lot. Your setting of AUXR is correct. If you have any PDATA or XDATA variables that are initialized at compile time (have values prior to executing Main), you need to set AUXR in STARTUP.A51. Do it immediately after the label "STARTUP1:".

    STARTUP calls C_Start to initialize variables after clearing RAM. Thus, it needs to have AUXR set correctly or internal RAM will be used for the first 256/768 (RC2/RD2) bytes of XDATA.

    Also, be careful with P2. If you use PDATA make sure it points to the correct page for your data.

    Just a final note. I always add the following:

    sfr   CKCON = 0x8F;             // Clock control register  

    The latest production of the chip drops the "H" and adds the clock control register. In your main program initialization set CKCON=1. This forces use of a 6x clock and allows all the peripheral devices (timers etc) to run at full speed. The instruction execution on an "H" variate has no ill effects.

  • Hi Bob,

    I am so glad to receive your reply and thank you so much for your kind advice. It saved me a lot of time....and now I can go to enjoy a cup of coffee.

    Thanks again and have a nice day.

    Cheers,
    Simon