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.

OnBoard_stack_used() function causes memory-safety fault condition

Other Parts Discussed in Thread: CC2538

Hi all, 

I'm using ZStack on CC2538, IAR 7.20, Smart Energy Profile, 

I was wondering if someone there who is good with the CC2538 and  ZStack memory management could help me:

When I call "OnBoard_stack_used()", the processor calls the FaultISR condition. When I trace the calls, FaultISR is called when execution reaches this line in the function listed below:

" if (STACK_INIT_VALUE == *ptr) "

Function code, copied unaltered from OnBoard.c in ZStack:

/******************************************************************************
* @fn OnBoard_stack_used
*
* @brief Runs through the stack looking for touched memory.
*
* @param none
*
* @return Maximum number of bytes used by the stack.
*/
uint16 OnBoard_stack_used(void)
{
uint8 const *ptr;
uint8 cnt = 0;

for (ptr = CSTACK_END; ptr > CSTACK_BEG; ptr--)
{
if (STACK_INIT_VALUE == *ptr)
{
if (++cnt >= MIN_RAM_INIT)
{
ptr += MIN_RAM_INIT;
break;
}
}
else
{
cnt = 0;
}
}

return (uint16)(CSTACK_END - ptr + 1);
}

Perhaps there is another way to determine the used stack memory in ZStack?

Its always good to see what one's stack and heap are up to! I monitor the heap with "osal_heap_mem_used()" constantly.

Thanks for your time.