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

large (>8k) array in xdata, program running incorrectly

Hi guys,

I tried to construct a waveform with more than 6000 points. the program is like:

arg.h
. .
int xdata wave[6000]
. .
main(){
. .
for...{
wave[i]=i*10;
. }
.

it passed the compiling and linking.
it showed that xdata=12131.
but when i ran the program, it's actually showing a messed up waveform. it only works correctly when i reduced the size of the wave[] to 4000, which makes xdata=8131.

i m using version 7.2, and the xram on the board is 128k. i think it's something missing in the program but couldnt figure it out yet since i m just a beginner of mcu programing in c. any suggestion? i really appreciate it.

Parents
  • YOU NEED TO READ "THE BIBLE" (not just for this)
    the '51 is a harvard architecture

    ok. i read the flash memory part of the datasheet. it's for code and non-volatile data storage. does it mean that i can only put the codes there? i am not sure if i can use it as xram for xdata.
    It is for code only (and possibly some constants)

    if set up the memory >8k, say up to 64k, in EMI0CF, so all the memory beyond 8k is from the flash memory, or i actually need some memory chip
    do you play "air guitar"? then, possibly you can figure out how to use "air memory" :) YES, for more than 8k data memory you need an external RAM

    Erik

    here are the links to "the bible" Chapter 1 - 80C51 Family Architecture:
    www.nxp.com/.../80C51_FAM_ARCH_1.pdf
    Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set:
    www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
    Chapter 3 - 80C51 Family Hardware Description:
    www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf

Reply
  • YOU NEED TO READ "THE BIBLE" (not just for this)
    the '51 is a harvard architecture

    ok. i read the flash memory part of the datasheet. it's for code and non-volatile data storage. does it mean that i can only put the codes there? i am not sure if i can use it as xram for xdata.
    It is for code only (and possibly some constants)

    if set up the memory >8k, say up to 64k, in EMI0CF, so all the memory beyond 8k is from the flash memory, or i actually need some memory chip
    do you play "air guitar"? then, possibly you can figure out how to use "air memory" :) YES, for more than 8k data memory you need an external RAM

    Erik

    here are the links to "the bible" Chapter 1 - 80C51 Family Architecture:
    www.nxp.com/.../80C51_FAM_ARCH_1.pdf
    Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set:
    www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
    Chapter 3 - 80C51 Family Hardware Description:
    www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf

Children