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

Stack in XDATA?

I read in the manual that the stack cannot be located off-chip in XDATA. Can someone please confirm this? I was wondering what would happen if I modify the STARTUP.A51 to place the stack pointer in XDATA (don't want to try yet!). I was using Sandeep Dutta's freeware C compiler which did allow the stack in xdata, and was wondering why Keil does not allow it. I have a large program in a FLASH chip, and very little precious iDATA space left despite my best efforts, and now the program is going off in the weeds whenever I add routines, and I am 90% sure it is a stack space problem. Speed is not an issue. Thanks!

  • http://www-us2.semiconductors.philips.com/acrobat/various/80C51_FAM_HARDWARE_1.pdf page 2.

    "stack" in XRAM can only be a synthetic stack(software implemented LIFO). Many compilers can implement such a "stack", but it does slow things down some.

    A well thought out design and a good compiler usually makes the stack space sufficient. The trick is to think "how often, how time critical" every time a variable is placed in a given data area.

    Have fun,

    Erik

  • The hardware stack used by an 8031 is always located inside the CPU. This stack is used to store return adresses on call's to functions or on interrupts. It serves as well as temporary storage for registers which are saved by PUSH-opcodes. Registers are pushed especially in interrupts. The stack is adressed via SFR "SP".

    The size of an application is not a criteria for stack size. My current application occupies about 150kByte of CODE, but my CPU may use up to 64 bytes for stack purposes.

    How much stack did you assign for your application ? Are you using nested interrupts ? Which memory model do you use ? Did you try to move all local variables to XDATA ?

    HHK