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.

CC2530: How is the stack allocation done in compile time and how to monitor its use in runtime?

Part Number: CC2530

Hi,

I am trying to understand the memory reservation and usage of RAM for stack and heap.

In the IAR .map file

we can see that the stats presented at the end of compilation

Q1) 7.5kb of 8kb RAM is used for XDATA memory , what happens to the the remaining memory, is it used for stack or heap?

 212 855 bytes of CODE  memory (+             47 149 range fill )
      32 bytes of DATA  memory (+ 81 absolute )
   7 479 bytes of XDATA memory
     192 bytes of IDATA memory
       8 bits  of BIT   memory
     454 bytes of CONST memory

Q2) Here stack is mentioned in 2 places
XSTACK and ISTACK, how are the different? when are they used?

XSTACK               XDATA         00000001 - 00000400         400   rel    0
XDATA_Z              XDATA         00000401 - 0000100E         C0E   rel    0
XDATA_I              XDATA         0000100F - 00001135         127   rel    0
<XDATA_N> 1          XDATA         00001136 - 00001D37         C02   rel    0
<XDATA_ROM_C> 1      CONST         00008000 - 000081C5         1C6   rel    0
ISTACK               IDATA         00000040 - 000000FF          C0   rel    0

Q3) in the build commands there are 2 stack macros defined, how are the different? when are they used?

#                            -D_PDATA_STACK_SIZE=0x80                          #
#                            -D_XDATA_STACK_SIZE=0x400                         #

Q4) Are there any resources available to detect stack overflow in CC2530?

I have gone through the https://wwwfiles.iar.com/8051/webic/doc/EW8051_CompilerGuide.pdf but was unable to understand these differences.

Would be great to have a simpler explanation to start with
and understand in more details with reference of any resource that you may have?