|
7#
樓主 |
發表於 2007-6-24 22:04:46
|
只看該作者
這是我集合各位大大,與我專研後寫的程式,不知還有哪邊需要修改的地方
請各位大大指教了!!
#ps:<這是與PC端連接控制SEVER MOTOR的程式>
PWM0 EQU 40H
PWM1 EQU 41H
PWM2 EQU 42H
PWM3 EQU 43H
PWM4 EQU 44H
PWM5 EQU 45H
PWM6 EQU 46H
PWM7 EQU 47H
COUNT EQU 37H
CUT EQU 39H
PIN EQU 51H
PWM EQU 52H
PIN1 EQU 53H
ORG 00H
JMP START
ORG 23H
JMP INTERR
ORG 0BH
JMP T0_INT
ORG 30H
START:
MOV SP,#70H
MOV R1,#20H
MOV 21H,#00H
MOV IE,#10010000B
MOV SCON,#01110000B
MOV TMOD,#00100000B
MOV TH1,#0f3H
SETB TR1
SETB EA
SETB ET0
SETB ET1
MOV CUT,#0
MOV COUNT,#0
MOV PWM0,#12
MOV PWM1,#12
MOV PWM2,#12
MOV PWM3,#12
MOV PWM4,#12
MOV PWM5,#12
MOV PWM6,#12
MOV PWM7,#12
INTERR:
PUSH A
JBC T0,T0_INT
JNB RI,$
CLR RI
MOV A,SBUF
MOV 21H,A
XRL A,#40H
JZ C0
MOV A,21H
XRL A,#41H
JZ C1
MOV A,21H
XRL A,#42H
JZ C2
MOV A,21H
XRL A,#43H
JZ C3
MOV A,21H
XRL A,#44H
JZ C4
MOV A,21H
XRL A,#45H
JZ C5
MOV A,21H
XRL A,#46H
JZ C6
MOV A,21H
XRL A,#47H
JZ C7
MOV A,21H
JZ STOP
RETI
MAIN:
LCALL OUT
LJMP MAIN
DEL_H:
MOV R7,#1
L7:
MOV R6,#2
L6:
MOV R5,#17
DJNZ R5,$
DJNZ R6,L6
DJNZ R7,L7
RET
PWM_WIDTH:
MOV COUNT,@R0
LOOP1:
SETB TR0
JNB TF0,$
CLR TR0
DJNZ COUNT,LOOP1
CLR TR0
MOV CUT,#0
INC R0
RET
OUT:
MOV R0,#40H
C0:
SETB P1.0
MOV R7,#10
LCALL DEL_H
LCALL PWM_WIDTH
CLR P1.0
C1:
SETB P1.1
MOV R7,#10
LCALL DEL_H
LCALL PWM_WIDTH
CLR P1.1
C2:
SETB P1.2
MOV R7,#10
LCALL DEL_H
LCALL PWM_WIDTH
CLR P1.2
C3:
SETB P1.3
MOV R7,#10
LCALL DEL_H
LCALL PWM_WIDTH
CLR P1.3
C4:
SETB P1.4
MOV R7,#10
LCALL DEL_H
LCALL PWM_WIDTH
CLR P1.4
C5:
SETB P1.5
MOV R7,#10
LCALL DEL_H
LCALL PWM_WIDTH
CLR P1.5
C6:
SETB P1.6
MOV R7,#10
LCALL DEL_H
LCALL PWM_WIDTH
CLR P1.6
C7:
SETB P1.7
MOV R7,#10
LCALL DEL_H
LCALL PWM_WIDTH
CLR P1.7
SETB TR1
RET
STOP:
MOV P1,#FFH
MOV 20H,#5AH
AJMP T0_INT
T0_INT:
PUSH A
PUSH PSW
CLR TR0
MOV TH0,#>(25536-40)
MOV TL0,#<(25536-40)
INC CUT
SETB TR0
POP PSW
POP A
RETI
END |
|