C251 User's Guide

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.

NameDescription
CONFIGB251 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.
WSAWait State for PSEN#/RD#/WR# signal except region 01:xxxx.
XALEExtend ALE pulse.
RDRGRD# and PSEN# memory signal selection (RD1 and RD0 Bits).
PAGMPage mode selection.
INTRInterrupt mode selection.
EDFExtended data float (EDF) timing feature.
WSBWait State for PSEN#/RD#/WR# signal for region 01:xxxx.
EMAPEPROM/ROM Mapping.

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

NameDescription
EDATALENSpecifies 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.
XDATASTARTSpecifies the xdata address to start initializing to 10000H.
XDATALENIndicates the number of bytes of xdata to clear to 0. The default is 0.
HDATASTARTSpecifies the hdata address to clear to 10000H.
HDATALENSpecifies the number of bytes of hdata to clear to 0. The default is 0.
STACKSIZESpecifies 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.
IBPSTACKNot 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.
IBPSTACKTOPSpecifies 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.
XBPSTACKNot 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.
XBPSTACKTOPSpecifies 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.