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

📄 main.asm

📁 应用松翰母体开发的航模飞机的源代码!有舵机控制功能
💻 ASM
字号:
;***********************************************
start:
	nop
	call		PortInitial
	call		RAMInitial
	call		SysInitial
	call		pdelay100ms
	call		PortInitial
	call		RAMInitial
	call		SysInitial
		
;***********************************************

mainloop:
	mov	a,#5ah
	mov 	wdtr,a
;	call	mnchkrx
	call	mnint
	call	mnkey
	call	mnapp
	jmp	mainloop
	
;***********************************************
RAMInitial:
	clr	Y    				;Select bank 0
	mov	A,#0x2f
	b0mov	Z,A				;Set @YZ address from 7fh

ClrRAM10:
	clr	@YZ				;Clear @YZ content
	decms	Z  				;z = z - 1 , skip next if z=0
	jmp	ClrRAM10
	clr 	@YZ				;Clear address 0x00
;--------------------set some content----------------
;设定各控制脚归零点
	mov	a,#33
	b0mov	wingbuf,a
	b0mov	wingloadbuf,a	
;//	mov	a,#33		
	b0mov   empennagebuf,a	
	b0mov	empennageloadbuf,a
;//	mov	a,#33	
	b0mov   screwbuf,a
        b0mov	screwloadbuf,a
;//     b0mov	a,#20	
        b0mov   swingbuf,a
	b0mov   swingloadbuf,a	
	ret
;***********************************************
PortInitial:
	clr	p0
	clr	p1
	clr	p5

	mov	A,#00h  	;//don't Pull up p5,p1,p0 port
	b0mov	p0ur,a
	b0mov	P1UR,A
	mov	A,#0ffh 	
	b0mov	P5UR,A	
	
	mov	A,#0feh
	mov	p0m,a
	mov	A,#0ffh
	mov	P1M,A
	mov	A,#0ffh	
	mov	P5M,A
	
	nop
	nop
	nop
	clr	p0
	clr	p1
	clr	p5
	ret
;***********************************************
;**********************************************
;Name	:SysInitial
;Function:
;Input  :
;Output	:
;Register Used:
;***********************************************
SysInitial:
	clr	PFLAG			;pflag = x,x,x,x,x,c,dc,z
	mov  	A,#00h			;Clear watchdog timer and initial system mode
	b0mov	OSCM,A

	mov	A,#00110000B
	b0mov	T0M,A			; Set the T0 rate=Fcpu/64
	mov	A,#0h
	b0mov	T0C,A
	bclr	FT0enb			; Enable TIMER0
	bset	ft0ien			; Enable T0 interrupt
	bclr	ft0irq			; CLEAR TIMER0 INTERRUPT FLAG

	MOV	A,#01110100B
	B0MOV	TC0M,A			;Set the TC0 rate=Fcpu/2
	mov	A,#156;206;

;	MOV	A,#01100100B
;	B0MOV	TC0M,A			; Set the TC0 rate=Fcpu/64
;	mov	A,#206			;200us
	b0mov	TC0C,A			; Set the TC0 timer
	b0mov	tc0r,a
;	bclr fpwm0out
	b0bset	FTC0ENB			; Enable TIMER0
	bset	FTC0IEN			; Enable TC0 interrupt
	bclr	ftc0irq			; CLEAR TIMER0 INTERRUPT FLAG

			; Enable P00 interrup
	@P00_EDGE	2		;@P00_EDGE=1-->Rising Edge ,=2-->falling EDg,=3-->bi-direction;	
	b0bclr	FP00IRQ
	b0bset	FP00IEN	

	b0bset	FGIE			;//enable Interrupt gain
	ret

;***********************************************	
Pdelay100ms:
	mov	a,#100
	mov	r2,a
Pdelay1ms:
	mov	a,#100	
	mov	r1,a
Pdelay10us:
	jmp	$+1
	jmp	$+1
	jmp	$+1
	decms	r1
	jmp	Pdelay10us
	decms	r2
	jmp	Pdelay1ms
Pdelay90:
	ret	
	
	

⌨️ 快捷键说明

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