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

📄 ax_firm.asm

📁 mcs51,2051,x86系列MCU
💻 ASM
📖 第 1 页 / 共 5 页
字号:
;**************************************************************************
;**                                                                      **
;**                  I N T E L   P R O P R I E T A R Y                   **
;**                                                                      **
;**     COPYRIGHT (c)  1996, 1997 BY  INTEL  CORPORATION.  ALL RIGHTS    **
;**     RESERVED.                                                        **
;**$Modtime:   19 Dec 1996 14:40:00  $
;**$Revision:   1.0  $
;***************************************************************************


; Remarks about this code:
;*************************
; The code is in an absolute format starting at location 00:4000 hex
; This location should be used if this code is to be downloded through
; a serial RS232 port to the 8x930AX\Hx board with RISM programmed in
; the EPROM. The main code starts at label "main" located at 004080.
; There is no need to include the configuration bytes in this code
; because RISM already takes care of that.
;
; If users want to adapt this code to their own board or if they want
; to change the EPROM provided with the board with their own EPROM,
; then they need to relocate the code. They need to change the
; starting location to 0FF:0000 hex and the label main to 0FF:0080.
; They will also need to program the Chip Cconfiguration Bytes.
;
; This code should run on all assebmlers provided by third party
; vendors. Minimum changes may be required. Users may need to change
; the include files, and use the ones provided by the Third party
; vendor they are using.



;$INCLUDE (8x930AX.INC)  ;  you may need to change this file and use
                        ;  the one provided by the tool vendor you
                        ;  are using.

;$INCLUDE (ONE_OH.INC)   ; This file is provided by Intel
include 8x930AX.inc
include one_oh.inc

FIFO_SIZE             equ     008h
GET_COMMAND           equ     080h
EP1_RX_FIFO_SIZE      equ     40h      ;
EP1_TX_FIFO_SIZE      equ     40h      ; 64 bytes
EP2_TX_FIFO_SIZE      equ     08h     ; 8 bytes
EP3_TX_FIFO_SIZE      equ     08h     ; 8 bytes
EP1_TX_LOOP_BACK_FIFO_SIZE    equ  40h
EP1_RX_LOOP_BACK_FIFO_SIZE    equ  40h
EP2_TX_LOOP_BACK_FIFO_SIZE    equ  08h
EP2_RX_LOOP_BACK_FIFO_SIZE    equ  08h
EP3_TX_LOOP_BACK_FIFO_SIZE    equ  08h
EP3_RX_LOOP_BACK_FIFO_SIZE    equ  08h

SETUP_PHASE           equ     000h
DATA_PHASE            equ     001h
STATUS_PHASE          equ     002h


EP0_MAX_PACKET_SIZE     equ      08h
NULL_DATA_PACKET        equ     000h


              ;------------------------------------------------------
              ; The following variables are used by routines
              ; outside this file.
              ;------------------------------------------------------


;***************
; Program origin
;****************

ORG 00:4000h                 ; Change to ORG 0FF:0000h for your
                             ; own EPROM/design

RESET_VECTOR:       LJMP main

INT0_VECTOR:        LJMP $
                    ds      5

TIM0_VECTOR:        LJMP $
                    ds      5

INT1_VECTOR:        LJMP $
                    ds      5

TIM1_VECTOR:        LJMP $
                    ds      5

SER_VECTOR:         LJMP $
                    ds      5

TIM2_VECTOR:        LJMP $
                    ds      5

PCA_VECTOR:         LJMP $
                    ds 13

SOF_VECTOR:         LJMP SOF_ISR
                    ds 5

USB_FUNC_VECTOR:    LJMP FUNCTION_ISR
                    ds 5

SUS_RSM_VECTOR:      LJMP SUSPEND_RESUME_ISR
                    ds 25h

TRAP_VECTOR:         LJMP $
END_VECTORS:



              ;----------------------------------------------------
              ; If RISM is enabled, code dan start at 004000h.
              ; If RISM is not enabled, then the user must
              ; be programming ROM. Place the first byte of code at
              ; at FF0000h
              ;----------------------------------------------------


;SEGMENT CODE_SEGMENT

;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
;M---------------------------------------------------------------------M
;M                   MAIN                                              M
;M---------------------------------------------------------------------M
;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM

ORG 00:4080H                  ; Change to 0FF:0080 for you own
                              ; EPROM/design

main:

        mov     SP,     #LOW (STACK_DATA)
        mov     SPH,    #HIGH(STACK_DATA)   ; Let Linker place the stack.
        mov     DPXL,   #0ffh               ; Set DPXL to point at the FLASH device
                                            ; to access constants
        mov     P1, #0F9h

        lCall   INIT_VARIABLES              ; Initialize the RAM space as required
;       lcall   INIT_USERS_CODE             ; Call to USERS CODE FOR INTILIZATION
        lCall   INIT_USB
        lcall   InitUsbInterrupts
        setb    EA                          ; Enable Interrupts.

    ;    mov     EPINDEX, #01h               ; NAK TEST
    ;    mov     EPCON, #04h                 ; NAK TEST
        ljmp    ActiveLoop                  ; Jump over the ISR stubs to the main loop.

;COMMENT *------------------------------------------------------------
;Function name     : InitUsbInterrupts
;Brief Description : Initilizes all of the USB Interrupts needed for this part
;                  : to function as unconfigured function.
;Regs preserved    : No reg. is saved
;--------------------------------------------------------------------*
;
InitUsbInterrupts:
                                            ;----------------------------------------
                                            ;--- Enable Function Interrupts
                                            ;----------------------------------------
        orl     FIE,    #03h                ; Enable Function EP0 TX & RX ENpoint Interrupts.
        setb    SOFIE                       ; Enable SOF Interrupt
        orl     IEN1, #03h                  ; Enable Function, SOF & Suspend/Resume ISR
        ret





;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
;A---------------------------------------------------------------------A
;A                  ACTIVE LOOP                                        A
;A---------------------------------------------------------------------A
;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

;COMMENT *------------------------------------------------------------
;ISR Registers
;IF the user makes this into an ISR, they will need to save certain registers
;upon entry into this code.  The firmware has been writen such that the
;only registers which are modified in this code are A, R0, R1 & EPINDEX.
;While DPX is used within the code, it is saved locally only when needed.
;This will allow the ISR to run slightly faster.
;--------------------------------------------------------------------*

;COMMENT *------------------------------------------------------------
;Function name     : ActiveLoop
;Brief Description : This routine simply sets and clears P1.3 at a periodic rate
;                  : It purpose is to let the user know the part is alive.
;
;Regs preserved    : No reg. is saved
;--------------------------------------------------------------------*


ActiveLoop:


;------------------------------------------------------------------
;-- Heart Beat
;-- This code simple flashes P1.3 at a steady rate.  If the device is
;-- Not configured then the rate is 1/4 of what it would be when it's
;-- Configured because LC bit is toggled when configured.
;------------------------------------------------------------------

HeartBeat:


NoNAK:
        mov     WR0,    Heart1
        inc     WR0,    #1
        mov     Heart1, WR0
        cmp     WR0,    #7FFFh
        jl      ClearBit
        setb    P1.3
        ljmp    ActiveLoop
ClearBit:
        clr     P1.3
        ljmp    ActiveLoop



;----------------------------------------------------------------
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;S S                 SUSPEND/RESUME ISR
;SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
;----------------------------------------------------------------
;COMMENT *------------------------------------------------------------
;Function name     : SUSPEND_RESUME_ISR
;BrieS Description : Service the SUSPEND_RESUME Interrupt
;                  :
;Regs preserved    : Reg. A, B  & EPINDEX are saved
;--------------------------------------------------------------------*
;SCOPE

SUSPEND_RESUME_ISR:
         push   PSW
         push   PSW1
         push   ACC
         push   WR2

                                            ;---------------------------------
                                            ; First check to see if this was a
                                            ; USB reset.  This only happens if
                                            ; the code has already enabled the
                                            ; USB reset feature.
                                            ;---------------------------------
SUSPEND_LOOP:
         jb     GSUS, SUSPEND_EVENT

RESET_EVENT:
                                            ; ON CTI Chips this is a reset and is vectored here.

         anl    PCON1,  #0F7h               ; Clear Reset
;         lcall  UserResetRoutine           ; Let the user know a reset occured.
         mov    P1, #066h
         lcall  InitUsbInterrupts
         sjmp   ExitSuspendISR

SUSPEND_EVENT:

                                            ;---------------------------------------
                                            ; Temp Resume command
                                            ;---------------------------------------

                                            ; To force RWU to happen every time
                                            ; after a suspend, then un comment out the line
                                            ; below.

                                            ;---------------------------------
                                            ; Enabled the following feature if
                                            ; you want the device to automatically
                                            ; generate a RWU x seconds after a
                                            ; Suspend is detected.
                                            ;---------------------------------
IF 1==2
FORCE_RWU:
         mov   R11,        #00
         mov   RWUTimer+1, R11

         mov   R11,        PCON1
         anl   PCON1,      #0E0h
         cjne  A, #0C0h, LS_RESUME
         mov   R11,        #0Fh
         sjmp  ll1
LS_RESUME:

         mov   R11,        #04h
ll1:
         mov   RWUTimer  , R11
ENDIF
                                            ; END OF FORCE RWU


                                            ; If the user has loaded RWUTimer with
                                            ; non-zero value, the function will wait
                                            ; that many milliseconds and then do a RWU
         mov   R11,  RWUTimer               ; If timer is zero, do a normal suspend.
         orl   R11,  RWUTimer+1
         JZ    DoSuspend                    ; Otherwise wait a delay and then resume.




DoRWU:
         push WR0
         xrl  R0,    R0                     ; Load count into DR0
         mov  R1,    RWUTimer
         mov  R2,    RWUTimer+1
         mov  R3,    R0

WaitLoop:
         mov  P1,   R1
         dec  DR0,  #1h

         jne  WaitLoop

         setb RWU
         jb   RWU,   $                      ; Wait until RWU is done.
         pop  WR0

⌨️ 快捷键说明

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