⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 startup.a51

📁 增强型单片机UPSD33XX系列芯片做音频发生器例程。内含KEIL源码和PLD源码。
💻 A51
字号:
$NOMOD51
;------------------------------------------------------------------------------
;  STARTU32.A51:  This code is executed after processor reset.
;
;  Modified for uPSD Startup:
;     - Disable Watchdog timer - enable at beginning of user application
;     - Settup various IP prescalers to large values (lowers power requirements)
;       The IP device drivers wil need to initialize the prescaler to the right value
;
;
; Nov 2003 - Petr PFEIFER, updated, fixed USB startup bug
;
;------------------------------------------------------------------------------


;  User-defined Power-On Initialization of Memory (Clear 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    100H               ; the length of IDATA memory in bytes.

; *** NOTE: uPSD users need to fill in the following based on where SRAM memory mapped.

XDATASTART    equ    0H           ; the absolute start-address of XDATA memory
XDATALEN      equ    0H                 ; the length of XDATA memory in bytes.

PDATASTART    equ    0H           ; the absolute start-address of PDATA memory
PDATALEN      equ    0H                 ; the length of PDATA memory 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.


;------------------------------------------------------------------------------
;
;  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.
;
PPAGEENABLE   equ    0                    ; set to 1 if pdata object are used.
;
PPAGE         equ    0                                  ; define PPAGE number.
;
PPAGE_SFR     data   0A0H           ; SFR that supplies uppermost address byte
;               (most 8051 variants use P2 as uppermost address byte)
;
;------------------------------------------------------------------------------

; Standard SFR Symbols
ACC           data   0E0H
B             data   0F0H
SP            data   81H
DPL           data   82H
DPH           data   83H
EA            data   0A8H
WDKEY         data   0AEH
ASCL          data   095H
PSCL0L        data   0B1H
PSCL0H        data   0B2H
PSCL1L        data   0B3H
PSCL1H        data   0B4H
USCL          data   0E1H
UIEN          data   0E9H
UADR          data   0EEH
DDCCON        data   0D7H
S1CON         data   0D8H

PSW           data   0D0H

              name   ?C_STARTUP


?C_C51STARTUP segment CODE
?STACK        segment IDATA

              rseg   ?STACK
              ds     1

              extrn  CODE (?C_START)
              public ?C_STARTUP

              cseg   AT 0
?C_STARTUP:   ljmp   STARTUP1

              rseg   ?C_C51STARTUP

STARTUP1:

; uPSD specific initialization
              mov    A, #055H                        ; Disable Watch Dog Reset
              mov    WDKEY, A

              mov    A, #0FEH              ; Load pre-scalars with large value
              mov    ASCL, A                             ; Slow down ADC Logic
              mov    PSCL0L, A                           ; Slow down PWM Logic
              mov    PSCL0H, A
              mov    PSCL1L, A
              mov    PSCL1H, A
              mov    USCL, A                             ; Slow down USB Logic

              mov    A,#0         ; Disable DDC and DDC XRAM out of addr space
              mov    EA,A                             ; EA=0; disable all INTs
              mov    UADR, A                               ; Disable USB Logic
              mov    UIEN, A                               ; Disable USB Logic

              mov    DDCCON, A
              mov    S1CON, A                        ; Disable DDC I2C as well

              mov    PSW, A                                  ; register BANK 0


IF IDATALEN <> 0
              mov    R0,#IDATALEN - 1
              clr    A
IDATALOOP:    mov    @R0,A
              djnz   R0,IDATALOOP
ENDIF

IF XDATALEN <> 0
              mov    DPTR,#XDATASTART
              mov    R7,#LOW (XDATALEN)
IF (LOW (XDATALEN)) <> 0
              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
              mov    R0,#LOW (PDATASTART)
              mov    R7,#LOW (PDATALEN)
              clr    A
PDATALOOP:    movx   @R0,A
              inc    R0
              djnz   R7,PDATALOOP
ENDIF

IF IBPSTACK <> 0
EXTRN         data   (?C_IBP)

              mov    ?C_IBP,#LOW IBPSTACKTOP
ENDIF

IF XBPSTACK <> 0
EXTRN         data   (?C_XBP)

              mov    ?C_XBP,#HIGH XBPSTACKTOP
              mov    ?C_XBP+1,#LOW XBPSTACKTOP
ENDIF

IF PBPSTACK <> 0
EXTRN         data   (?C_PBP)
              mov    ?C_PBP,#LOW PBPSTACKTOP
ENDIF

              mov    SP,#?STACK-1                            ;#080H ;#?STACK-1
; This code is required if you use L51_BANK.A51 with Banking Mode 4
; EXTRN CODE (?B_SWITCH0)
;               CALL    ?B_SWITCH0      ; init bank mechanism to code bank 0
              ljmp   ?C_START

              end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -