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

external stack

Hello,

1)I would like to check the stack of the reentrant function in order to know that i don't have any overflow. Do you know how i can do it?
2) Is it possible to use an external stack (stack in xdata) without declaring the function as reentrant?

Thank you
Kaoru

Parents
  • The following was in Keils Knowlegebase:

    C51: CALCULATING STACK SIZE

    QUESTION
    How can I determine the maximum stack size of my program?

    ANSWER
    There is no automatic way the tools can tell you the maximum stack depth or stack utilization. Because of asynchronous events and interrupts, the automation is too difficult.
    However, you can manually determine the amount of stack space used by your program. You can use this method in either an in-circuit emulator or in the dScope debugger. The results should be similar.
    1. Locate the beginning of the stack. If you use the C51 compiler, look for the ?STACK symbol.
    2. Fill the stack area with a known value or string. Something like "STACK---", since it's 8 characters long, displays nicely in a memory dump.
    3. Run your program and make sure you execute every line of code (or as much as makes sense). Make sure you generate interrupts so that they are included in the profile. If your emulator has a code coverage feature, use it to make sure that every path is taken. You can do this with dScope's code coverage feature.
    4. After your program runs a while, stop it and look at the stack area. You should see garbage for the part of the stack that has been used and the "STACK---" strings in the remainder of the stack. Count the number of complete strings, multiply by 8 (since "STACK---" is 8 bytes long), and you have the number of bytes of remaining stack space.

Reply
  • The following was in Keils Knowlegebase:

    C51: CALCULATING STACK SIZE

    QUESTION
    How can I determine the maximum stack size of my program?

    ANSWER
    There is no automatic way the tools can tell you the maximum stack depth or stack utilization. Because of asynchronous events and interrupts, the automation is too difficult.
    However, you can manually determine the amount of stack space used by your program. You can use this method in either an in-circuit emulator or in the dScope debugger. The results should be similar.
    1. Locate the beginning of the stack. If you use the C51 compiler, look for the ?STACK symbol.
    2. Fill the stack area with a known value or string. Something like "STACK---", since it's 8 characters long, displays nicely in a memory dump.
    3. Run your program and make sure you execute every line of code (or as much as makes sense). Make sure you generate interrupts so that they are included in the profile. If your emulator has a code coverage feature, use it to make sure that every path is taken. You can do this with dScope's code coverage feature.
    4. After your program runs a while, stop it and look at the stack area. You should see garbage for the part of the stack that has been used and the "STACK---" strings in the remainder of the stack. Count the number of complete strings, multiply by 8 (since "STACK---" is 8 bytes long), and you have the number of bytes of remaining stack space.

Children