How to find the maximum stack usage ?

Hi I am working on nrf52840 dk project. I want to find out the maximum stack usage of the program.I searched in the devzone support forum and stumbled upon this method to find the address

of the stack.

void print_stack_pointer() 
{
  uint32_t * ptr = NULL;
  printf("Stack pointer is %p \n", (uint32_t)&ptr);
}

I found this helpful but I can not find the runtime stack usage of the program. Another method was to paint the whole stack with a predefined value like '0xDEADBEEF'. I am skeptical about the effects of this method as I dont want to modify any startup code because of this. Is there a simple way to find the maximum stack usage? Thank you.

Parents Reply Children
No Data
Related