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

📄 int.asm

📁 基本完成迷控制算法
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;**************************************
;	Initial Interrupt 	      *
;**************************************
@@init_int:
	clr	inten
	clr	intrq
 IF @ChipP00INT == 1
;P00
;	b0bset	fp00ien			; enable p00 interrupt
 ENDIF
 IF @ChipP01INT == 1
;P01
	b0bset	fp01ien			; enable p01 interrupt
 ENDIF
 IF @ChipP02INT == 1
;P02
	b0bset	fp02ien			; enable p02 interrupt
 ENDIF
 IF @ChipT0INT == 1
;Timer (T0)
;	b0bclr	ft0enb		; To disable T0 timer		
	mov 	A,@SysT0m	; sET t0 RATE=XXX
	b0mov	T0M,A		; tO SET t0 CLOCK=FCPU/XX	
	mov	A,@SysT0c   	; SET INITIAL t0 BASETIME= XXMS
	b0mov	T0C,A	
	
	b0bset	ft0ien	   	; To enable T0 interrupt service
	b0bset	ft0enb	   	; To enable T0 timer
 ENDIF
 IF @ChipTC0INT == 1
; Timer/Event0 (TC0)
;	b0bclr	ftc0enb		; To disable Tc0 timer/event	
	mov 	A,@SysTc0m	; Set tC0 RATE=XXX
	b0mov	TC0M,A		; To set Tc0 clock=fcpu/xx	
	mov	A,@SysTc0c   	; SET INITIAL tC0 BASETIME= XXMS
	b0mov	TC0C,A
   if @SysTc0R_set == 1
   	b0mov	TC0R,a
   	b0bset	faload0
   endif	
	b0bset	ftc0ien	   	; To enable Tc0 interrupt service
	b0bset	ftc0enb	   	; To enable Tc0 timer
 ENDIF	
 IF @ChipTC1INT == 1
; Timer/Event1 (TC1)
;	b0bclr	ftc1enb		; To disable Tc1 timer/event	
	mov 	A,@SysTc1m	; Set Tc1 rate=xxx
	b0mov	TC1M,A		; To set Tc1 clock=fcpu/xx	
	mov	A,@SysTc1c   	; SET INITIAL tC1 BASETIME= XXMS
	b0mov	TC1C,A
   if @SysTc1R_set == 1
   	b0mov	TC1R,a
   	b0bset	faload1
   endif	
	b0bset	FTC1IEN	   	; To enable Tc1 interrupt service
	b0bset	FTC1ENB	   	; To enable Tc1 timer
 ENDIF
 IF @ChipSIOINT == 1
 	mov	a,@Siom_set
 	b0mov	siom,a
 	b0bset	fsioien
 ENDIF
	ret
;************************************************
;	Interrupt Service Routine		*
;************************************************
@@int_rs:
	b0xch	a,accbuf		; save a
	b0mov	a,pflag			; save pflag		
	b0mov	pflagbuf,a
;	PUSH
;	b0mov	a,y		; if you use y,z,r,x,h,l in interrupt routine,please add these structions!
;	b0mov	ybuf,a		;			|
;	b0mov	a,z		;			|
;	b0mov	zbuf,a		;			|
;	b0mov	a,r		;			|
;	b0mov	rbuf,a		;			|
;	b0mov	a,x		;			|
;	b0mov	xbuf,a		;			|
;	B0MOV	a,h		;			|
;	B0MOV	hbuf,a		;			|
;	B0MOV	a,l		;			|
;	B0MOV	lbuf,a		; if you use y,z,r,x,h,l in interrupt routine,please add these structions!
;*******************************
;auto check proper interrupt   *
;*******************************
 IF @ChipP00INT == 1
; Is P00 Interrupt 
	b0bts1	fp00ien
	jmp	@f
	b0bts0	fp00irq	
	jmp 	@@Int_P00
@@:	
 ENDIF
 IF @ChipP01INT == 1
; Is P01 Interrupt 
	b0bts1	fp01ien
	jmp	@f
	b0bts0	fp01irq	
	jmp 	@@Int_P01
@@:
 ENDIF
 IF @ChipP02INT == 1
; Is P02 Interrupt 
	b0bts1	fp02ien
	jmp	@f
	b0bts0	fp02irq	
	jmp 	@@Int_P02	
@@:	
 ENDIF
 IF @ChipT0INT == 1
; Is T0 Interrupt 
	b0bts1	ft0ien
	jmp	@f
	b0bts0	ft0irq
	jmp	@@Int_T0
@@:
 ENDIF	
 IF @ChipTC0INT == 1
; Is Timer 0 Interrupt 
	b0bts1	ftc0ien
	jmp	@f
	b0bts0	ftc0irq	
	jmp	@@Int_Tc0
@@:
 ENDIF
 IF @ChipTC1INT == 1
; Is Timer 1 Interrupt 
	b0bts1	ftc1ien
	jmp	@f
	b0bts0	ftc1irq	
	jmp	@@Int_Tc1	
@@:
 ENDIF
 IF @ChipSIOINT == 1
; Is Sio Interrupt 
	b0bts1	fsioien
	jmp	@f
 	b0bts0	fsioirq
 	jmp	@@Int_Sio
@@:
 ENDIF
 IF @ChipADCINT == 1
; Is A/D Interrupt
	b0bts1	fadcien
	jmp	@f
	b0bts0	fadcirq
	jmp	@@Int_ADC
@@:
 ENDIF	
	
; End interrupt!
@@Int_rs90:
	b0mov	a,pflagbuf		
	b0mov	pflag,a	
;	POP	
;	b0mov	a,ybuf		; if you use y,z,r,x,h,l in interrupt routine,please add these structions!
;	b0mov	y,a		;			|
;	b0mov	a,zbuf		;			|
;	b0mov	z,a		;			|
;	b0mov	a,rbuf		;			|
;	b0mov	r,a		;			|
;	B0MOV	a,xbuf		;			|
;	B0MOV	x,a		;			|
;	B0MOV	a,hbuf		;			|
;	B0MOV	h,a		;			|
;	B0MOV	a,lbuf		;			|
;	B0MOV	l,a		; if you use y,z,r,x,h,l in interrupt routine,please add these structions!		
	b0xch	a,accbuf
	reti
;**********************************************
;       Exterior interrupt service     	      *
;**********************************************
 IF @ChipP00INT == 1	
@@int_p00:                        			
;service for interrupt!
	jmp	RF_Falling_detect
		RF_Falling_detect_ret:
	b0bclr	fp00irq	
	jmp	@@Int_rs90
 ENDIF
;----------------------------------
IF @ChipP01INT == 1	
@@int_p01:                       		
;service for interrupt!
//	................
//	................
	b0bclr	fp01irq	
	jmp	@@Int_rs90
 ENDIF
;----------------------------------
 IF @ChipP02INT == 1	
@@int_p02:     
;service for interrupt!
//	................
//	................
	b0bclr	fp02irq	
	jmp	@@Int_rs90
 ENDIF
;----------------------------------
 IF @ChipT0INT == 1
;Timer0  xmS
@@Int_T0:           
;	b0bclr	ft0ien		; To disable T0 interrupt service
;	b0bclr	ft0enb		; To disable T0 timer
	mov	a,@SysT0m	;
	b0mov	t0m,a		; To set T0 clock = fcpu /xx
	mov	a,@SysT0c  	; 
	b0mov	t0c,a           ; 
;service for interrupt!
//	................
//	................	
     IF @Systimer_set == 1
	b0bset	@Sys5msIRQ
     ENDIF
     	b0bset	ft0ien		; To enable T0 interrupt service
	b0bset	ft0enb		; To enable T0 timer
	b0bclr	ft0irq		; To clear T0 interrupt request	
	jmp	@@Int_rs90
 ENDIF
;----------------------------------
 IF @ChipTC0INT == 1
;Timer/Event0  xmS
@@int_tc0:     
     IF @SysTc0R_set == 0      
;	b0bclr	ftc0ien		; To disable Tc0 interrupt service
;	b0bclr	ftc0enb		; To disable Tc0 timer
	mov	a,@SysTc0m	;
	b0mov	tc0m,a		; To set Tc0 clock = fcpu /xx
	mov	a,@SysTc0c  	; 
	b0mov	tc0c,a          ; 
     ENDIF
;service for interrupt!
	jmp	RF_Timecount_pro
		RF_Timecount_pro_ret:
	jmp	Motor_process
		Motor_process_ret:
//	................
//	................	
     IF @Systimer_set == 2
     	decms	intwk00
     	jmp	@f
     	mov	a,#5
     	mov	intwk00,a        	 
	b0bset	@Sys1msIRQ
     @@:
     ENDIF
     	b0bset	ftc0ien		; To enable Tc0 interrupt service
	b0bset	ftc0enb		; To enable Tc0 timer
	b0bclr	ftc0irq		; To clear Tc0 interrupt request	
	jmp	@@Int_rs90
 ENDIF

 IF @ChipTC1INT == 1
;----------------------------------
;Timer/Event1  xmS
@@Int_Tc1: 
     IF @SysTc1R_set == 0              
;	b0bclr	ftc1ien		; To disable Tc1 interrupt service
;	b0bclr	ftc1enb		; To disable Tc1 timer
	mov	a,@SysTc1m	;
	b0mov	tc1m,a		; To set Tc1 clock = fcpu /xx
	mov	a,@SysTc1c  	; 
	b0mov	tc1c,a          ; 
     ENDIF
;service for interrupt!
//	................
//	................	
     IF @Systimer_set == 3
	b0bset	@Sys5msIRQ
     ENDIF
     	b0bset	ftc1ien		; To enable Tc1 interrupt service
	b0bset	ftc1enb		; To enable Tc1 timer
	b0bclr	ftc1irq		; To clear Tc1 interrupt request	
	jmp	@@Int_rs90
 ENDIF  

 IF @ChipSIOINT == 1
;********************************
;          Sio interrupt        *
;********************************
@@Int_sio:
;service for interrupt!
//	............
//	............
	b0bclr	fsioirq
	jmp	@@Int_rs90
 ENDIF 
 
 IF @ChipADCINT == 1
;********************************
;	ADC Interrupt		*
;********************************
@@Int_ADC:
;service for interrupt!
//	............
//	............
	b0bclr	fadcirq
	jmp	@@Int_rs90
  ENDIF	
	
;*********************************
;	Interrupt Interface	 *
;*********************************
@@INTface_init:
        clr	@intgnd		  ;Int interface register

     ifdef   @Sys2msIRQ
        mov_	@Sys2msC,@Sys2msStep	;set the steps of 2ms INT   
     endif
     ifdef   @Sys50msIRQ
        mov_	@Sys50msC,@Sys50msStep	;set the steps of 50ms INT   
     endif
     ifdef   @Sys100msIRQ
        mov_	@Sys100msC,@Sys100msStep	;set the steps of 100ms INT    
     endif
     ifdef   @Sys200msIRQ
        mov_	@Sys200msC,@Sys200msStep	;set the steps of 200ms INT    
     endif
     ifdef   @Sys300msIRQ
        mov_	@Sys300msC,@Sys300msStep	;set the steps of 300ms INT  
     endif
     ifdef   @Sys400msIRQ
        mov_	@Sys400msC,@Sys400msStep	;set the steps of 400ms INT    
     endif
     ifdef   @Sys500msIRQ
        mov_	@Sys500msC,@Sys500msStep	;set the steps of 500ms INT   
     endif
     ifdef   @Sys600msIRQQ
        mov_	@Sys600msC,@Sys600msStep	;set the steps of 600ms INT    
     endif
     ifdef   @Sys700msIRQ
        mov_	@Sys700msC,@Sys700msStep	;set the steps of 700ms INT       
     endif
     ifdef   @Sys800msIRQ
        mov_	@Sys800msC,@Sys800msStep	;set the steps of 800ms INT    
     endif
     ifdef   @Sys900msIRQ
        mov_	@Sys900msC,@Sys900msStep	;set the steps of 900ms INT    
     endif
     ifdef   @Sys1sIRQ
        mov_	@Sys1sC,@Sys1sStep	;set the steps of 1s INT      
     endif
     ifdef   @Sys5sIRQ
        mov_	@Sys5sC+0,@Sys5sStepL	;set the steps of 5s INT
        mov_	@Sys5sC+1,@Sys5sStepH	;set the steps of 5s INT
     endif
     ifdef   @Sys10sIRQ
        mov_    @Sys10sC+0,@Sys10sStepL	;set the steps of 10s INT
        mov_    @Sys10sC+1,@Sys10sStepH	;set the steps of 10s INT
     endif
     ifdef   @Sys30sIRQ
        mov_    @Sys30sC+0,@Sys30sStepL	;set the steps of 30s INT
        mov_    @Sys30sC+1,@Sys30sStepH	;set the steps of 30s INT
     endif
     ifdef   @Sys60sIRQ
        mov_    @Sys60sC+0,@Sys60sStepL	;set the steps of 60s INT
        mov_    @Sys60sC+1,@Sys60sStepH	;set the steps of 60s INT
     endif
     ifdef   @Sys300sIRQ
        mov_    @Sys300sC+0,@Sys300sStepL	;set the steps of 300s INT
        mov_    @Sys300sC+1,@Sys300sStepH	;set the steps of 300s INT
     endif
	ret
;**********************************
;   Interrupt Interface Routine   *
;**********************************
@@IntFace:
        b0mov	a,@intgnd
        jz	@@Intface99
  if @Systimer_set != 0
;check Interface request
	ifdef	@Sys1msIRQ
 b0bts1  @Sys1msIRQ
 jmp	 @f
 ;call	Motor_process
 call    @@SysTimer
 bclr	 @sys1msirq
 @@:
        endif

        ifdef   @Sys10msIRQ
        b0bts0  @Sys10msIRQ
        call    @@Intface10ms
        endif

        ifdef   @Sys50msIRQ
        b0bts0  @Sys50msIRQ
        call    @@Intface50ms
        endif

        ifdef   @Sys100msIRQ
        b0bts0  @Sys100msIRQ
        call    @@Intface100ms
        endif

        ifdef   @Sys200msIRQ
  ;      b0bts0  @Sys200msIRQ
  ;      call    @@Intface200ms
        endif

        ifdef   @Sys300msIRQ
        b0bts0  @Sys300msIRQ
        call    @@Intface300ms
        endif

        ifdef   @Sys400msIRQ
        b0bts0  @Sys400msIRQ
        call    @@Intface400ms
        endif

        ifdef   @Sys500msIRQ
        b0bts0  @Sys500msIRQ
        call    @@Intface500ms
        endif

        ifdef   @Sys600msIRQQ
        b0bts0  @Sys600msIRQQ
        call    @@Intface600ms
        endif

        ifdef   @Sys700msIRQ
        b0bts0  @Sys700msIRQ
        call    @@Intface700ms
        endif

⌨️ 快捷键说明

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