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

Is there a way to check the stack size during runtime?

Is there a way to check the stack size during runtime?

I use a Freescale K10 MCU.

Parents
  • You can do it before or after calling main(), but it has to be done in a manner that does not destroy the content of the running stack. I haven't done this on ARM, so I can't tell you the exact details. But I presume there is a way to find where the stack is (and its size) perhaps from some global variables, and just make a pointer and fill the stack using this pointer in a loop.

Reply
  • You can do it before or after calling main(), but it has to be done in a manner that does not destroy the content of the running stack. I haven't done this on ARM, so I can't tell you the exact details. But I presume there is a way to find where the stack is (and its size) perhaps from some global variables, and just make a pointer and fill the stack using this pointer in a loop.

Children
  • Hi,

    with RTX, create U64 taskStack[STACKSIZE/8] arrays, and memset them to 0xcc in the main function before creating a task.
    Then simply add this variable to the watch Window and let your application run.

    The stack gets filled from top, the last entry you see is the magic word which gets checked by the OS.

    By counting the remaining "0xcc" you can see the maximal stack usage.

    BR,
    /th.