?? main.asm
字號(hào):
;***********************************************
start:
nop
call PortInitial
;// call RAMInitial
;// call SysInitial
;// call pdelay100ms
call PortInitial
call RAMInitial
call SysInitial
;***********************************************
;// b0bclr fgie
mainloop:
;// jmp mainloop
;-----------------------------------------------
;//test mode
looplow:
/*
b0bclr ptwing
mov_ r1,#80
call Pdelay10us
mov a,#2
add r2,a
mov a,r2
cmprs a,#19
jmp $+3
mov a,#1
mov r2,a
mov a,r2
mov r1,a
b0bset ptwing
;// mov_ r1,#1
call Pdelay10us
b0bclr ptwing
nop
*/
;------
/*
b0bclr ptwing
mov_ r2,#160
call Pdelay100us ;50us
b0bset ptwing
mov_ r2,#50
call Pdelay100us ;50us
*/
;// jmp looplow
;-----------------------------------------------
mov a,#5ah
mov wdtr,a
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----------------
;設(shè)定各控制腳歸零點(diǎn)
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,#01010000B
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; ;50us//100us
b0mov TC0C,A ;Set the TC0 timer,Fcpu=4mips
b0mov tc0r,a
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
;***********************************************
Pdelay100us:
mov a,#5
mov r1,a
Pdelay10us:
jmp $+1
jmp $+1
;// jmp $+1
decms r1
jmp Pdelay10us
decms r2
jmp Pdelay100us
Pdelay90:
ret
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -