Keil Logo

Startup Code

The START251.A51 file contains the startup code for a C251 target program. This source file is located in the \KEIL\C251\LIB directory. Include a copy of this file in each 251 project that needs custom startup code.

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

  • Clears near data memory
  • Clears xdata data memory
  • Clears far data memory
  • Clears paged external data memory
  • Initializes the 251 hardware stack pointer
  • Transfers control to the main C function

The START251.A51 file contains some definitions at the beginning which are used for the hardware configuration of the 251 MCU and for the setup of the C runtime system.

The functions of the individual EQU statements are described below.

Name Description
CONFIGB 251 Configuration Bytes Definition for off chip (external) config bytes. Set this definition to 1 if you want to generate the 251 configuration byte information at address 0xFFFFF8 and 0xFFFFF9.
WSA Wait State for PSEN#/RD#/WR# signal except region 01:xxxx.
XALE Extend ALE pulse.
RDRG RD# and PSEN# memory signal selection (RD1 and RD0 Bits).
PAGM Page mode selection.
INTR Interrupt mode selection.
EDF Extended data float (EDF) timing feature.
WSB Wait State for PSEN#/RD#/WR# signal for region 01:xxxx.
EMAP EPROM/ROM Mapping.

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

Name Description
EDATALEN Specifies the number of bytes of edata to be initialized to 0. The default is 420h because most 251 derivatives contain at least 1056 bytes of on-chip edata memory.
XDATASTART Specifies the xdata address to start initializing to 10000H.
XDATALEN Indicates the number of bytes of xdata to clear to 0. The default is 0.
HDATASTART Specifies the hdata address to clear to 10000H.
HDATALEN Specifies the number of bytes of hdata to clear to 0. The default is 0.
STACKSIZE Specifies the number of bytes used as hardware stack area. The STACKSIZE value must be adjusted according to the actual requirements of the application. The default is 100H bytes for stack size.
IBPSTACK Not required in C251 Version 2 or higher, only for compatibility to C51 & C251 Version 1.x. Indicates 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 C51 or C251 Version 1 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 Not required in C251 Version 2 or higher, only for compatibility to C51 & C251 Version 1.x. Indicates 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 start address of the large model reentrant stack area. The default is 0xFFFF in idata memory.
The C51 or C251 Version 1 compiler does not check to see if the stack area available satisfies the requirements of the applications. It is your responsibility to perform such a test.
  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.