电路衔接(如图一):
元器件(80c51芯片,8255A芯片,74ls373锁存芯片,l298驱动芯片,三相六线步进电机,按钮若干,电源)
汇编源程序:
ORG 0000H;
LJMP MAIN1;
ORG 0030H;(头文件)
MAIN1:MOV DPTR,#0FF7FH;检测PA口状况
MOV A,#91H;
MOVX @DPTR,A;
MAIN:MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L1;
LJMP MAIN;
L1:CJNE A,#0FEH,LOOP2;
LOOP1:MOV DPTR,#0FF7DH;操控电机正转
MOV A,#01H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L2;
LJMP MAIN;
L2:CJNE A,#0FEH,LOOP2;
MOV DPTR,#0FF7DH;
MOV A,#02H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L3;
LJMP MAIN;
L3:CJNE A,#0FEH,LOOP2;
MOV DPTR,#0FF7DH;
MOV A,#04H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L4;
LJMP MAIN;
L4:CJNE A,#0FEH,LOOP2;
L8:LJMP LOOP1;
LOOP2:MOV DPTR,#0FF7DH;操控电机回转
MOV A,#01H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L5;
LJMP MAIN;
L5:CJNE A,#0FCH,LOOP1;
MOV DPTR,#0FF7DH;
MOV A,#04H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L6;
LJMP MAIN;
L6:CJNE A,#0FCH,LOOP1;
MOV DPTR,#0FF7DH;
MOV A,#02H;
MOVX @DPTR,A;
LCALL DELAY;
MOV DPTR,#0FF7CH;
MOVX A,@DPTR;
CJNE A,#0FFH,L7;
LJMP MAIN;
L7:CJNE A,#0FCH,L8;
LJMP LOOP2;
DELAY:MOV R5,#0H;延时子程序
K1:MOV R6,#02H;
K2:MOV R7,#81H;
K3:NOP;
DJNZ R7,K3;
DJNZ R6,K2;
DJNZ R5,K1;
RET;
END;