This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

What is the different stack usage in CC2430?(ISTACK and XSTACK)

Other Parts Discussed in Thread: CC2430, CC2530, Z-STACK

I am little bit confused by the stack usage in CC2430. Normally we can use stack in data memory pointed by SP. It is ISTACK.

but CC2430 also use XDATA segment to hold stack, it defines XSP as its stack pointer as:

// Internal (MCU) Stack addresses
#define CSTK_PTR _Pragma("segment=\"XSP\"") __segment_begin("XSP")
#define CSTK_BEG _Pragma("segment=\"XSTACK\"") __segment_begin("XSTACK")
#define RSTK_END _Pragma("segment=\"ISTACK\"") __segment_end("ISTACK")

accoring to zmain_ram_init(), it seems all call parameters are in XSTACK, and return address is in ISTACK, so it seems most of stack usage is in XDATA area. Am I right? The CPU will automatically assign function call parameters and return address to different stack? What is the reason to do like this way?

If there is some long function call chain or recursive function call, which part of stack is more likely to face stack overflow?

Thanks

Rui

  • You are correct about the usage of XSTACK and ISTACK. Since IDATA is so small, it's more flexible to put call parameters in XSTACK, the size of which can be "tuned" by the user according to their application needs. For that reason, it depends on the user's XSTACK size, coupled with number of parameters passed on function calls, to determine which stack will overflow first on a long function call chain.

  • thanks for your response.

    How about the local variable, It is in ISTACK? Also We can tune the size of XSTACK stack size, but can we adjust the size of ISTACK(since it is bounded by the 256 Byte DATA segment size?). Also the address of ISTACK seems overlapped the SFR address. how the CPU can differ them?

    There is one function OnBoard_stack_used() to check the stack usage, is this to check XSTACK usage or ISTACK usage?

    thanks

    Rui

  • Local variables are placed in the XSTACK. I have no experience adjusting the size of ISTACK.

  • thanks, I saw IAR EW8051 IDE tool can change both ISTACK or XSTACK, is that ture? Also for the developer, do we need to worry where our parameters, local variables. etc are placed? For example, can we adjust the call parameter place from XSTACK to ISTACK?

    thanks

  • I'm building serialapp rpoject wilth zstack 2.5.1a for cc2530

    IAR shows that the xstack required size is 0xFD9, but xstack we defined is 0x300. Will this cause a stack overflow problem?

    ->Sub-tree of type: Function tree
    XSTACK ISTACK
    | Stack used (prev) : 00000FD9 0000012D
    01 strlen::?relay
    | Stack used (prev) : 00000FD9 0000012D
    | + function block : 00000000 00000000
    <-Sub-tree of type: Function tree
    | Stack used : 00000FD9 0000012D

  • Hi wisper,

    I think you use the latest IAR 8.30 to build Z-Stack 2.5.1a, don't you. Please use IAR 8.10 because Z-Stack 2.5.1a is built by IAR 8.10.