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

uVision 4 compiler memory allocation

Hi All,

I am using DS89C450 MCU and writing my C code using uVision 4 compiler. In my DS89, I had a SRAM of 1kB and I would like to declare a 500 variable of unsigned char therefore I use

unsigned char xdata IR[500];

When I compiler with uVision 4, it show no error and therefore I burn the Hex code into my MCU. However, when I write and then read the IR[500], it give incorrect value

I therefore proceed to use debugger to troubleshoot my code and everything works fine in the debugger. My code does not have any problem.

Therefore I suspect uVision 4 had assign the IR[500] to non SRAM location and therefore the value is actually not written and read.

I would like to know how can I make sure uVision4 assign the SRAM location correctly and is there any setting I need to set before compiling?

Pls help. Thanks a lot

Parents
  • Hi All Expert, Thanks for your comment. Will go and check how to enable the internal SRAM of my MCU and how to set the uVision4 to compile to the correct address. But Some things still puzzled me and I hope you all can enlighten me.

    From the memory map of my DS89C450 (I cant attached the jpg here so I will just spell out), it show something like this

    00 - FF (128 bytes SFR)

    0000 - 1FFF (8kB x 8 Flash Memory Program)

    2000 - 3FFF (8kB x 8 Flash Memory Program)

    0000 - 03FF (1kB x 8 SRAM, Data OR program memory address from 400 - 7FF)

    4000 - FFFF (External Program Memory)

    0000 - 03FF - FFFF (External Data memory, 0000 - 03FF non-usable if internal SRAM is activiated)

    My question is
    1) Why there is an overlap of program memory and data memory from 0000 to FFFF?
    2) Does it means that we have 2 x FFFF of memory inside the MCU?
    3) Where does the 00 to FF SFR saved as the address is also overlap?

    Thanks alot

Reply
  • Hi All Expert, Thanks for your comment. Will go and check how to enable the internal SRAM of my MCU and how to set the uVision4 to compile to the correct address. But Some things still puzzled me and I hope you all can enlighten me.

    From the memory map of my DS89C450 (I cant attached the jpg here so I will just spell out), it show something like this

    00 - FF (128 bytes SFR)

    0000 - 1FFF (8kB x 8 Flash Memory Program)

    2000 - 3FFF (8kB x 8 Flash Memory Program)

    0000 - 03FF (1kB x 8 SRAM, Data OR program memory address from 400 - 7FF)

    4000 - FFFF (External Program Memory)

    0000 - 03FF - FFFF (External Data memory, 0000 - 03FF non-usable if internal SRAM is activiated)

    My question is
    1) Why there is an overlap of program memory and data memory from 0000 to FFFF?
    2) Does it means that we have 2 x FFFF of memory inside the MCU?
    3) Where does the 00 to FF SFR saved as the address is also overlap?

    Thanks alot

Children