Keil Logo

Startup Code

Startup code is executed immediately upon reset of the target system. The Keil startup code performs (optionally) the following operations in order:

  • Clears internal data memory
  • Clears external data memory
  • Clears paged external data memory
  • Initializes the small model reentrant stack and pointer
  • Initializes the large model reentrant stack and pointer
  • Initializes the compact model reentrant stack and pointer
  • Initializes the 8051 hardware stack pointer
  • Transfers control to code that initializes global variables or to the main C function if there are no initialized global variables

Following is a list of the startup files that are available.

Startup File Description
STARTUP.A51 Startup code for classic 8051 devices.
START_AD.A51 Startup code for Analog Devices MicroConverter devices.
START390.A51 Startup code for Dallas DS80C390/400/41x/5240/5250 contiguous mode devices.
START4XX.A51 Startup code for Dallas DS89C420/430/440/450 devices.
STARTLPC.A51 Startup code for NXP LPC700 devices series.
START900.A51 Startup code for NXP LPC90x - LPC93x devices series.
START950.A51 Startup code for NXP LPC95x - LPC99x devices series.
START_MX.A51 Startup code for NXP 80C51MX devices.
START751.A51 Startup code for NXP 80C75x devices.
START_XC.A51 Startup code for Infineon XC800 devices.
STARTUP32.A51 Startup code for ST uPSD32xx devices.
STARTUP34.A51 Startup code for ST uPSD33xx devices.
STARTUP34.A51 Startup code for ST uPSD34xx devices.

Copy the appropriate startup file from the \KEIL\C51\LIB\ folder into your project folder and make any changes to the copy.

Each startup file provides assembly constants you may change to control the operations performed at startup.

Name Description
IDATALEN Specifies the number of bytes of idata to clear to 0. The default is 80h because most 8051 derivatives contain at least 128 bytes of internal data memory. Use a value of 100h for the 8052 and other derivatives that have 256 bytes of internal data memory.
XDATASTART Specifies the initial xdata address to clear to 0.
XDATALEN Indicates the number of bytes of xdata to clear to 0. The default is 0.
PDATASTART Specifies the initial pdata address to clear to 0.
PDATALEN Specifies the number of bytes of pdata to clear to 0. The default is 0.
IBPSTACK Specifies whether or not the small model reentrant stack pointer (?C_IBP) should be initialized. A value of 1 causes this pointer to be initialized. A value of 0 prevents initialization of this pointer. The default is 0.
IBPSTACKTOP Specifies the top of the small model reentrant stack. The default is 0xFF in idata memory.

The Cx51 Compiler does not check to see if the stack area available satisfies the requirements of the application. It is your responsibility to perform such a test.
XBPSTACK Specifies whether or not the large model reentrant stack pointer (?C_XBP) should be initialized. A value of 1 causes this pointer to be initialized. A value of 0 prevents initialization of this pointer. The default is 0.
XBPSTACKTOP Specifies the top of the large model reentrant stack. The default is 0xFFFF in xdata memory.

The Cx51 Compiler does not check to see if the stack area available satisfies the requirements of the application. It is your responsibility to perform such a test.
PBPSTACK Specifies whether the compact model reentrant stack pointer (?C_PBP) should be initialized. A value of 1 causes this pointer to be initialized. A value of 0 prevents initialization of this pointer. The default is 0.
PBPSTACKTOP Specifies the top of the compact model reentrant stack. The default is 0xFF in pdata memory.

The Cx51 Compiler does not check to see if the stack area available satisfies the requirements of the application. It is your responsibility to perform such a test.
PPAGEENABLE Enables (a value of 1) or disables (a value of 0) Port 2 initialization for pdata memory access. The default is 0. pdata addressing uses Port 2 for the upper address (or page) byte.
PPAGE

Specifies the value to write to Port 2 of the 8051 for pdata memory access. This value represents the xdata memory page to use for pdata. This is the upper 8 bits of the absolute address range to use for pdata. For example, if the pdata area begins at address 1000h (page 10h) in xdata memory, PPAGEENABLE should be set to 1, and PPAGE should be set to 10h. You must specify the starting pdata address to use to the BL51 Linker using the PDATA directive. For example:

BL51 input modules PDATA (1050H)

Neither the BL51 Linker nor the Cx51 Compiler checks to see if the PDATA directive and the PPAGE startup constant are correctly specified. You must ensure that these parameters contain suitable values.

  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.