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

📄 jiaobanqi.asm

📁 带LED显示
💻 ASM
📖 第 1 页 / 共 3 页
字号:
MODE3_10: 
         B0BSET    OUTPUT_PAUSE
         MOV       A,_SPD_9500
         B0MOV     R_SPEED,A    
         B0BTS1    TIME_T
         RET
         B0BCLR    TIME_T
         DECMS     TIME_MS
         RET
         MOV       A,_TIME_MS
         B0MOV     TIME_MS,A
         DECMS     TIME_SEC
         RET
         B0BCLR    FC
         RLCM      MODE_STATUS
         MOV       A,#2
         B0MOV     TIME_SEC,A
         RET 
MODE3_11:
         B0BSET    OUTPUT_PAUSE
         MOV       A,_SPD_17100
         B0MOV     R_SPEED,A    
         B0BTS1    TIME_T
         RET
         B0BCLR    TIME_T
         DECMS     TIME_MS
         RET
         MOV       A,_TIME_MS
         B0MOV     TIME_MS,A
         DECMS     TIME_SEC
         RET
         B0BCLR    FC
         RLCM      MODE_STATUS
         MOV       A,#2
         B0MOV     TIME_SEC,A
         RET   
MODE3_12:
         B0BCLR    OUTPUT_PAUSE
         B0BTS1    TIME_T
         RET
         B0BCLR    TIME_T
         DECMS     TIME_MS
         RET
         MOV       A,_TIME_MS
         B0MOV     TIME_MS,A
         DECMS     TIME_SEC
         RET
         B0BCLR    FC
         RLCM      MODE_STATUS
         MOV       A,#2
         B0MOV     TIME_SEC,A
         RET   
MODE3_13:
         B0BSET    OUTPUT_PAUSE
         MOV       A,_SPD_17100
         B0MOV     R_SPEED,A    
         B0BTS1    TIME_T
         RET
         B0BCLR    TIME_T
         DECMS     TIME_MS
         RET
         MOV       A,_TIME_MS
         B0MOV     TIME_MS,A
         DECMS     TIME_SEC
         RET
         MOV       A,#3
         B0MOV     TIME_SEC,A
         B0BCLR    FC
         RLCM      MODE_STATUS
         DECMS     MODE3_CIRCLE
         JMP       $+2       
         RET
         MOV       A,#1
         B0MOV     MODE_STATUS,A
         RET  

;---------------------------------------
GO_MODE4: 
         MOV      A,_SPD_10000
         MOV      R_SPEED,A
         RET
;---------------------------------------
GO_MODE5: 

         MOV      A,_SPD_19000
         MOV      R_SPEED,A
         RET
;-------------------------------------------------------------------------------
; F_DELAY (DELAY Service Routine)
; Arguments	: 
; Returns	: 
; Reg Change    : 
;-----------------------------------------------------------------------------
F_DELAY:
        MOV     A,_DLY_BUFF3
        B0MOV   DELAY_BUFF3,A 
DELAY_LOOP:
        NOP
        NOP
        NOP
        DECMS   DELAY_BUFF3
        JMP     DELAY_LOOP
        RET
        

;-------------------------------------------------------------------------------
; Isr (Interrupt Service Routine)
; Arguments	: 
; Returns	: 
; Reg Change    : 
;-------------------------------------------------------------------------------
/*
Processing multi-interrupt request needs to set the priority of these interrupt requests.
The IRQ flags of the 7 interrupt are controlled by the interrupt event occurring. But the
IRQ flag set doesn't mean the system to execute the interrupt vector. The IRQ flags can be
triggered by the events without interrupt enable. Just only any the event occurs and the 
IRQ will be logic "1".
There are two things need to do for multi-interrupt. One is to make a good priority for
these interrupts. Two is using IEN and IRQ flags to decide executing interrupt service 
routine or not.
*/

Isr:
;-------------------------------------
;	Save ACC and system registers
;-------------------------------------
        PUSH
;-----------------------------------
;   Check which interrupt happen
;-----------------------------------
;-----------------------------------
;   Check which interrupt happen
;-----------------------------------

INTP00CHK:					; Check INT0 interrupt request
	B0BTS1	FP00IEN				; Check P00IEN
	JMP	INTTC0CHK			; Jump check to next interrupt
	B0BTS0	FP00IRQ				; Check P00IRQ
	JMP	INTP00				; Jump to INT0 interrupt service routine
;;INTP01CHK:					; Check INT1 interrupt request
;;	B0BTS1	FP01IEN				; Check P01IEN
;;	JMP	INTTC0CHK			; Jump check to next interrupt
;;	B0BTS0	FP01IRQ				; Check P01IRQ
;;	JMP	INTP01				; Jump to INT1 interrupt service routine
;INTP02CHK:					; Check INT2 interrupt request
; 	B0BTS1	FP02IEN				; Check P02IEN
;	JMP	INTT0CHK			; Jump check to next interrupt
;	B0BTS0	FP02IRQ				; Check P02IRQ
;	JMP	INTP02				; Jump to INT2 interrupt service routine
INTTC0CHK:					; Check TC0 interrupt request
	B0BTS1	FTC0IEN				; Check TC0IEN
	JMP	INTT0CHK			; Jump check to next interrupt
	B0BTS0	FTC0IRQ				; Check TC0IRQ
	JMP	INTTC0				; Jump to TC0 interrupt service routine
INTT0CHK:					; Check TC1 interrupt request
	B0BTS1	FT0IEN				; Check TC1IEN
	JMP	INT_EXIT			; Jump check to next interrupt
	B0BTS0	FT0IRQ				; Check TC1IRQ
	JMP	INTT0				; Jump to TC1 interrupt service routine

;-----------------------------------
; Exit interrupt service routine
;-----------------------------------

INT_EXIT:
;;        B0MOV  A,PFLAGBUF
;;        B0MOV  PFLAG,A
	POP					; Restore 80h ~ 87h system registers			
;;	b0xch	A,AccBuf			; B0xch instruction do not change C,Z flag
        NOP
        NOP
	reti					; Exit the interrupt routine



;-------------------------------------------------------------------------------
;	INP00 interrupt service routine
;-------------------------------------------------------------------------------
;;Process P0.0 external interrupt here
;-------------------------------------------------------------------------------
INTP00:
        B0BTS0   INPUT_50HZ           ;PREVENT NOISE INTERRUTPT
        JMP      DEBOUNCE_H
        JMP      DEBOUNCE_L
DEBOUNCE_H:
        NOP
        NOP
        NOP
        NOP  
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        B0BTS1   INPUT_50HZ
        JMP      P00OUT  
        JMP      P00_TRUE
DEBOUNCE_L:
        NOP
        NOP
        NOP
        NOP  
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        B0BTS0   INPUT_50HZ
        JMP      P00OUT  
        JMP      P00_TRUE



P00_TRUE:
        B0BSET   TRIGGLE_FLAG
        B0BTS0   R_SPEED.0       ;DELAY TIME FOR TRIGGLE
        MOV      A,_TIME_19000
        B0BTS0   R_SPEED.1
        MOV      A,_TIME_18300
        B0BTS0   R_SPEED.2
        MOV      A,_TIME_17100
        B0BTS0   R_SPEED.3
        MOV      A,_TIME_15200
        B0BTS0   R_SPEED.4
        MOV      A,_TIME_13300
        B0BTS0   R_SPEED.5
        MOV      A,_TIME_10000
        B0BTS0   R_SPEED.6
        MOV      A,_TIME_9500
	B0MOV	 TC0C,A 
        B0BCLR   FTC0IRQ
        B0BSET   TRIGGLE_FLAG
        MOV      A,_SLEP_DLY
        B0MOV    R_SLEPTIME,A

P00OUT:
        B0BCLR   FP00IRQ
      	JMP	 INT_EXIT



;-------------------------------------------------------------------------------
;	TC0 interrupt service routine
;-------------------------------------------------------------------------------
;Process TC0 timer interrupt here
;--------------------------------------------------------------------------------
INTTC0:
        
        B0BTS1  TRIGGLE_FLAG
        JMP     TC0OUT1             ;WAIT FOR 50HZ TRIGGLE
        B0BCLR  TRIGGLE_FLAG
        B0BTS1  OUTPUT_PAUSE  
        JMP     TC0OUT1             ;OUTPUT PAUSE
        B0BTS0  OVERLOAD_FLAG        
        JMP     TC0OUT1             ;OVERLOAD STOP

        B0BCLR  BT_TRIGGLE
DELAY_CL:
        DECMS   DELAY_BUFF
        JMP     DELAY_CL
        B0BSET  BT_TRIGGLE
        MOV     A,_DLY_BUFF
        B0MOV   DELAY_BUFF,A        

TC0OUT1:
        MOV	A,#0    
	B0MOV	TC0C,A 
        B0BCLR  FTC0IRQ
      	JMP	INT_EXIT
;-------------------------------------------------------------------------------
;	T0 interrupt service routine
;-------------------------------------------------------------------------------
;Process TC1 timer interrupt here
;-------------------------------------------------------------------------------
INTT0:
	
        B0BSET  TIME_T
        DECMS   R_SLEPTIME
        JMP     INTT0_EXT
        B0BCLR    OUTPUT_PAUSE
        CLR       MODE_FLAG
INTT0_EXT:
        MOV	A,#100     
	B0MOV	T0C,A 
        b0bclr	FT0IRQ
	jmp	INT_EXIT

;-------------------------------------------------------------------------------
;	SysInit
; 	Initialize I/O, Timer, Interrupt, etc.
;-------------------------------------------------------------------------------
SysInit:
        B0BSET  BT_TRIGGLE
        MOV     A,#10100110B
        B0MOV   P5M,A            ;SET PORT50,3,4,6  TO INPUT,PORT51,2,5,7  TO OUTPUT
        
	MOV     A,#00000000B
        B0MOV   P0M,A            ;SET PORT0 TO INPUT
        
        MOV     A,#00001101B     ;PORT10,2,3 SET OT OUTPUT OTHERS SET OT INPUT
        B0MOV   P1M,A
 
        MOV     A,#00000100B
        B0MOV   P1,A
        CLR     P5

        MOV     A,#01011001B     ;ENABLE P50,3,4,6 PULL UP REGISTER 
        B0MOV   P5UR,A

        MOV     A,#00000000B     ;DISABLE PO PULL UP  
        B0MOV   P0UR,A

        MOV     A,#00000010B     ;ENABLE P11 PULL UP 
        B0MOV   P1UR,A

        MOV     A,#00011000B
        B0MOV   PEDGE,A

        CLR     INTRQ
        CLR     INTEN            ;DISABLE ALL INTERRUT

        MOV	A,#40H
	B0MOV	T0M,A	
	MOV	A,#100     
	B0MOV	T0C,A           ;T0 INTERRUPT PER 5MS
	B0BCLR  FT0IRQ
	B0BSET	FT0ENB		;Enable TC0 timer
        B0BSET  FT0IEN

        MOV	A,#40H
	B0MOV	TC0M,A    
	MOV	A,#107 
	B0MOV	TC0C,A 	        ;STEP FOR 32US UP COUNTER
	B0BCLR  FTC0IRQ
	B0BSET	FTC0ENB		;Enable TC0 timer
        B0BSET  FTC0IEN
        NOP
        NOP
        RET

;-------------------------------------------------------------------------------
; ClrRAM
; Use index @YZ to clear RAM  (00h~7Fh)
;-------------------------------------------------------------------------------

ClrRAM:
	clr	Y    				;Select bank 0 
	b0mov	Z,#0x2F                 	;Set @YZ address from 2Fh

ClrRAM10:
	clr	@YZ				;Clear @YZ content
	decms	Z  				;z = z - 1 , skip next if z=0
	jmp	ClrRAM10
 	clr 	@YZ				;Clear address 0x00
        NOP
        NOP
        RET
;-------------------------------------------------------------------------------
        NOP
        NOP
        NOP
        NOP
        jmp	Reset1
	ENDP

⌨️ 快捷键说明

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