Menu

1 / 10

Master C/C++ Stack Usage and Get More From Your Device

Planet Qt·4 days ago
#46SWs8RH
#planetqt#qt#pragma#stack#usage
Long article (2050 words) — no AI summary yet.
Reading 0:00
15s threshold

In this article, we will take a look at the stack usage analysis functionality available in the IAR Embedded Workbench and introduce some techniques on how to calculate the maximum stack usage of your application at building time, as well as track the signs of stack pointer at runtime.

Background

The stack is a fixed block of continuous memory and has to be allocated statically by the developer. It contains local data for C/C++ functions, e.g.:

Local variables which are not stored in registers

Function parameters which are not stored in registers

Temporary result of expressions

The return value of a function (unless it is passed through registers)

Interrupt contexts

Processor registers that should be restored before the function returns

A stack can be divided into two parts. The first part contains allocated memory used by functions and the second part contains free memory that can be allocated.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.