步进电机控制之8255A
元器件(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;
步进电机控制8255 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)