Keil Logo

System Stack

The system stack stores return addresses and registers used for local register variables. For interrupt functions, the system stack saves the PSW, CP, and status of the MUL/DIV unit. The size of the system stack area is defined and initialized in the startup code which is executed before the C main function is called. The startup code also sets the values for the STKOV (stack overflow) and STKUN (stack underflow) registers.

The default value of the system stack is 256 words which is typically enough for most complex applications. However, if the system stack overflows, a stack overflow trap (interrupt 4) is generated. This signals that the system stack is too small.

Note

  • Programs may swap the system stack area to external memory in the event of a stack overflow or underflow. However, the interrupt reaction time becomes unpredictable when this feature is used. In addition, you may encounter problems saving and restoring the MDL/MDH registers. Therefore, we recommend that you do not incorporate stack swapping features in your applications.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.