$NOMOD51 ;Ax51 macro assembler control command: disable predefined 8051
;------------------------------------------------------------------------------
; This file is part of the C51 Compiler package
; Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
;------------------------------------------------------------------------------
; STARTUP.A51: This code is executed after processor reset.
; STARTUP.A51: The code generated by the STARTUP.A51 file will be executed after the microcontroller is reset!
; To translate this file use A51 with the following invocation:
;
A51 STARTUP.A51
;
; To link the modified STARTUP.OBJ file to your application use the following ;
BL51 invocation: ; BL51 , STARTUP.OBJ ; ;------------------------------------------------------------------------------ ; ; User-defined Power-On Initialization of Memory ; ; With the following EQU statements the initialization of memory ; at processor reset can be defined : ; the absolute start-address of IDATA memory is always 0 IDATALEN EQU 80H ; the length of IDATA memory in bytes. ; IDATA (indirect addressing area) has a fixed starting address of 0; IDATALEN is used to specify the length of the IDATA area to be initialized (in bytes)*
XDATASTART EQU 0H ; the absolute start-address of XDATA memory
XDATALEN EQU 0H ; the length of XDATA memory in bytes.
;XDATA (External Direct Addressing Area) XDATASTART is used to specify the starting address of the XDATA area to be initialized
; XDATALEN is used to specify the length of the XDATA area to be initialized (in bytes)*
PDATASTART EQU 0H ; the absolute start-address of PDATA memory
PDATALEN EQU 0H ; the length of PDATA memory in bytes.
;PDATA (Page Addressing Area) PDATASTART is used to specify the starting address of the PDATA area to be initialized
; PDATALEN is used to specify the length of the PDATA area to be initialized (in bytes)*
; Notes: The IDATA space overlaps physically the DATA and BIT areas of the
; 8051 CPU. At minimum the memory space occupied from the C51
; run-time routines must be set to zero.
;Note: The IDATA area in 8051 physically includes the DATA area (direct addressing area) and the BIT area (bit addressing area). C51 (library) occupies the minimum memory space, and the program needs to set it to 0 during runtime
;------------------------------------------------------------------------------
;
; Reentrant Stack Initilization
;
The following EQU statements define the stack pointer for reentrant ;
functions and initialized it: ; Stack Space for reentrant functions in the SMALL model. ; IBPSTACK EQU 0 ; set to 1 if small reentrant is used. ; IBPSTACKTOP EQU 0FFH+1 ; set top of stack to highest location+ 1 . ; Stack Space for reentrant functions in the LARGE model. ; XBPSTACK EQU 0 ; set to 1 if large reentrant is used. ; XBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1. ; ; Stack Space for reentrant functions in the COMPACT model. ; PBPSTACK EQU 0 ; set to 1 if compact reentrant is used. ; PBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1. ; ; ------------------------------------------------------------------------------ ; ; Page Definition for Using the Compact Model with 64 KByte xdata RAM ; The following EQU statements define the xdata page used for pdata ; variables. The EQU PPAGE must conform with the PPAGE control used ; in the linker invocation. ; The following EQU statements define the use of the XDATA page for the PDATA variable PPAGEENABLE EQU 0 ; set to 1 if pdata object are used. ; PPAGE EQU 0 ; define PPAGE number. ; Define page number ; PPAGE_SFR DATA 0A0H ; SFR that supplies uppermost address byte ; (most 8051 variants use P2 as uppermost address byte) ; (most 8051 variants use P2 as uppermost address byte) ;------------------------------------------------------------------------------
; Standard SFR Symbols
; Standard SFR Symbols
ACC DATA 0E0H
B DATA 0F0H
SP DATA 81H
DPL DATA 82H
DPH DATA 83H
NAME ?C_STARTUP
?C_C51STARTUP SEGMENT CODE
?STACK SEGMENT IDATA
RSEG ?STACK
DS 1
EXTRN CODE (?C_START)
; External code (this label will represent the starting address of the user program)
PUBLIC ?C_STARTUP
; Symbol for external use
CSEG AT 0
; Place the following code at address 0 of the code segment (use AT instructions to locate the absolute address)
?C_STARTUP: LJMP STARTUP1
RSEG ?C_C51STARTUP
STARTUP1:
IF IDATALEN <> 0
; If the length is greater than 1, initialize IDATA
MOV R0, #IDATALEN - 1
CLR A
IDATALOOP: MOV @R0, A
DJNZ R0, IDATALOOP
ENDIF
IF XDATALEN <> 0
; If the length is greater than 1, initialize XDATA
MOV DPTR,#XDATASTART
MOV R7,#LOW (XDATALEN)
IF (LOW (XDATALEN)) <> 0
; Preset the number of external loops during initialization to R6
MOV R6,#(HIGH (XDATALEN)) +1
ELSE
MOV R6,#HIGH (XDATALEN)
ENDIF
CLR A
XDATALOOP: MOVX @DPTR,A
INC DPTR
DJNZ R7,XDATALOOP
DJNZ R6,XDATALOOP
ENDIF
IF PPAGEENABLE <> 0
MOV PPAGE_SFR,#PPAGE
ENDIF
IF PDATALEN <> 0
;If the length is greater than 1, initialize PDATA
MOV R0,#LOW (PDATASTART)
MOV R7,#LOW (PDATALEN)
CLR A
PDATALOOP: MOVX @R0,A
INC R0
DJNZ R7,PDATALOOP
ENDIF
IF IBPSTACK <> 0
; When using reentrant functions in SMALL mode, set the stack
EXTRN DATA (?C_IBP)
MOV ?C_IBP,#LOW IBPSTACKTOP
ENDIF
IF XBPSTACK <> 0
; Stack EXTRN DATA to be set when using reentrant functions in COMPACT mode
(?C_XBP)
MOV ?C_XBP,#HIGH XBPSTACKTOP
MOV ?C_XBP+1,#LOW XBPSTACKTOP
ENDIF
IF PBPSTACK <> 0
;Stack to be set when using reentrant functions in LARGE mode
EXTRN DATA (?C_PBP)
MOV ?C_PBP,#LOW PBPSTACKTOP
ENDIF
MOV SP,#?STACK-1
; This code is required if you use L51_BANK.A51 with Banking Mode 4
; If your program uses Mode 4 program grouping technology (BANKING), please enable the following program code
; EXTRN CODE (?B_SWITCH0)
; CALL ?B_SWITCH0 ; init bank mechanism to code bank 0
; The program starts from the first block (bank0)
LJMP ?C_START ; Jump to your program entry from here
END
;*******************************************************************
The original project did not include the startup.A51 file, and the program sometimes had garbled characters and pointer overflow, causing system abnormalities. After adding this file, for the C8051F340 microcontroller 4K Xdata, I sampled the following settings:
; ; Stack Space for reentrant
functions in the LARGE model. ; XBPSTACK EQU 1 ; set to 1 if large reentrant is used. ; XBPSTACKTOP EQU 0FFFH+1; set top of stack to highest location+1. ;
The system is now running stably!
Previous article:51 Values in MCU
Next article:Design and Implementation of Embedded Real-time Control Module Based on C51
Recommended ReadingLatest update time:2024-11-16 12:43
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- How to read electrical control circuit diagrams (Classic best-selling books on electronics and electrical engineering) (Zheng Fengyi)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Problems encountered in B-U585I-IOT02A test
- [FS-IR02 + D1CS-D54] - 4: Linking with MCU (FS-IR02)
- [Atria Development Board AT32F421 Review] TEST06 CFFT related tests
- EasyARM-RT1052 Review] + Basic IoT transmission framework (final post)
- TCP/IP Detailed Explanation (Layer 7/Layer 4 Protocol)
- FPGA Selection Strategy.pdf
- How to connect esp8266 and pyboard using UART
- Medical device requirements for chip temperature
- Send Chip Coins: #What to do when you encounter problems with Guoxin#, technical support is rubbed on the ground?
- 【RPi PICO】MicroPython firmware with encryption support