Keil Logo

C51: Defining the Minimum Stack Size


Information in this article applies to:

  • C51 All Versions

QUESTION

When I define more and more data and idata variables in my application, the available stack space decreases. By default, only one byte is reserved for the stack, which is not enough for my application. I want to make sure that the remaining stack space is at least 20 bytes. If I define too many data and idata variables, the linker should report an error message.

ANSWER

This is possible. The stack size is defined in the STARTUP code. You may copy the STARTUP.A51 file from the \Keil\C51\LIB folder to your project folder and add this file to your µVision project. Then, the stack size can be modified in this file.

?C_C51STARTUP   SEGMENT   CODE
?STACK          SEGMENT   IDATA

                RSEG    ?STACK
                DS      1

The line DS 1 specifies the stack size. You may change this value according to your needs.

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  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.