发表于:2005/9/26 9:51:00
#0楼
下面是我的程序!请指教!
$include(c8051F040.inc)
$include(easycore.inc)
$include(EASYCORE.LIB)
;$include(user_data.inc)
;***********************************
ORG 0E000H
ORG 0E003H
ORG 0E013H
ORG 0E033H
ORG 0E03BH
ORG 0E043H
ORG 0E04BH
ORG 0E053H
ORG 0E05BH
ORG 0E063H
ORG 0E07BH
ORG 0E083H
ORG 0E08BH
ORG 0E093H
;*****用户应用程序调用入口*********************
ORG 0E0A0H
LJMP USER_CONFIG
ORG 0E0A3H
LJMP USER_START
ORG 0E0A6H
LJMP USER_SET_INIT
ORG 0E0A9H
LJMP USER_RUN_INIT
ORG 0E0ACH
LJMP USER_SCAN
ORG 0E0B0H
LJMP USER_STEP
ORG 0E0B3H
LJMP USER_TMS
ORG 0E100H
;*******************USER_CONFIG******************
USER_CONFIG:
MOV P3MDIN , #0FFH ;端口3为开关量输入模式
MOV P1MDOUT, #0FFH ;端口1输出模式为推挽
MOV P2MDOUT, #0FFH ;端口2输出模式为推挽
ORL P4MDOUT, #00FH ;
ORL P0MDOUT, #00FH ;
R_PY EQU 20H
R_PX EQU 21H
I0 EQU P3.0
I1 EQU P3.1
I2 EQU P3.2
I3 EQU P3.3
I4 EQU P3.4
I5 EQU P3.5
I6 EQU P3.6
I7 EQU P3.7
O0 EQU P1.0
O1 EQU P1.1
O2 EQU P1.2
O3 EQU P1.3
O4 EQU P1.4
O5 EQU P1.5
ILED0 EQU P2.0
ILED1 EQU P2.1
ILED2 EQU P2.2
ILED3 EQU P2.3
ILED4 EQU P2.4
ILED5 EQU P2.5
ILED6 EQU P2.6
ILED7 EQU P2.7
OLED0 EQU P0.4
OLED1 EQU P0.5
OLED2 EQU P0.6
OLED3 EQU P0.7
OLED4 EQU P4.1
OLED5 EQU P4.0
RUN EQU P4.3
ERR EQU P4.2
;*************USER_START*********************
USER_START:
MOV R_PX, #00H
MOV R_PY, #00H
CLR I0
CLR I1
CLR I2
CLR I3
CLR I4
CLR I5
CLR I6
CLR I7
CLR O0
CLR O1
CLR O2
CLR O3
CLR O4
CLR O5
CLR ILED0
CLR ILED1
CLR ILED2
CLR ILED3
CLR ILED4
CLR ILED5
CLR ILED6
CLR ILED7
CLR OLED0
CLR OLED1
CLR OLED2
CLR OLED3
CLR OLED4
CLR OLED5
SETB RUN
CLR ERR
RET
;**************USER_RUN_INIT***************
USER_RUN_INIT:
JB PLC_PRO_ERR, LED_ERR
CLR ERR
JB KEY_SET, LED_RUN
SETB RUN
RET
LED_ERR:
SETB ERR
RET
LED_RUN:
CLR RUN
RET
;************USER_SET_INIT**************
USER_SET_INIT:
; RAM_PY EQU 0180H
; RAM_PX EQU 0240H
RET
;*************USER_STEP**************************
USER_STEP:
MOV DPTR , #RAM_PX
MOVX A , @ DPTR
MOV R_PX , A
MOV DPTR , #RAM_PY
MOVX A , @DPTR
MOV R_PY, A
MAIN:
JB R_PX.0 , IL0
JB R_PX.1 , IL1
JB R_PX.2 , IL2
JB R_PX.3 , IL3
JB R_PX.4 , IL4
JB R_PX.5 , IL5
JB R_PX.6 , IL6
JB R_PX.7 , IL7
JB R_PY.0, OLED_OUT0
JB R_PY.1, OLED_OUT1
JB R_PY.2, OLED_OUT2
JB R_PY.3, OLED_OUT3
JB R_PY.4, OLED_OUT4
JB R_PY.5, OLED_OUT5
BACK_USER:
RET
OLED_OUT0:
SETB OLED0
SETB O1
RET
OLED_OUT1:
SETB OLED1
SETB O2
RET
OLED_OUT2:
SETB OLED2
SETB O2
RET
OLED_OUT3:
SETB OLED3
SETB O3
RET
OLED_OUT4:
SETB OLED4
SETB O4
RET
OLED_OUT5:
SETB OLED5
SETB O5
RET
IL0:
MOV R2 , #8
IL0P:
JNB I0 ,BACK_USER
DJNZ R2 , IL0
JB I0 , ILED_OUT0
RET
IL1:
MOV R2, #8
IL1P:
JNB I1 , BACK_USER
DJNZ R2 , IL1P
JB I1 , ILED_OUT1
RET
IL2:
MOV R2 , #8
IL2P:
JNB I2 , BACK_USER
DJNZ R2 , IL2P
JB I2 , ILED_OUT2
RET
IL3:
MOV R2 , #8
IL3P:
JNB I3 , BACK_USER
DJNZ R2 , IL3P
JB I3 , ILED_OUT3
RET
IL4:
MOV R2 , #8
IL4P:
JNB I4 , BACK_USER
DJNZ R2 , IL4P
JB I4 , ILED_OUT4
RET
IL5:
MOV R2 , #8
IL5P:
JNB I5 , BACK_USER
DJNZ R2 , IL5P
JB I5 , ILED_OUT5
RET
IL6:
MOV R2, #8
IL6P:
JNB I6 , BACK_USER
DJNZ R2 , IL6P
JB I6 , ILED_OUT6
RET
IL7:
MOV R2, #8
IL7P:
JNB I7, BACK_USER
DJNZ R2 , IL7P
JB I7, ILED_OUT7
RET
ILED_OUT0:
SETB ILED0
RET
ILED_OUT1:
SETB ILED1
RET
ILED_OUT2:
SETB ILED2
RET
ILED_OUT3:
SETB ILED3
RET
ILED_OUT4:
SETB ILED4
RET
ILED_OUT5:
SETB ILED5
RET
ILED_OUT6:
SETB ILED6
RET
ILED_OUT7:
SETB ILED7
RET
;**************USER_TMS*****************
USER_TMS:
RET
;***************USER_SCAN****************
USER_SCAN:
LJMP DELAY
CLR I0
CLR I1
CLR I2
CLR I3
CLR I4
CLR I5
CLR I6
CLR I7
CLR O0
CLR O1
CLR O2
CLR O3
CLR O4
CLR O5
RET
DELAY:
MOV R7 , #100; 2.5MS*100*4=1S
DJNZ R7, DELAY1
RET
DELAY1:
MOV R6, #4
DJNZ R6, DELAY1
JMP DELAY
END
**内容隐藏回复可见**