電路圖我已經畫好了 不過...我家沒有話電路圖的軟體所以我用小畫家畫小些不足的地方請多包含!!有些零件沒標示清楚請再說一下http://www.wretch.cc/album/show.php?i=romext9476&b=2&f=1228835359&p=1
程式碼
TB10 EQU 30H
TB2 EQU 31H
RTB10 EQU 32H
RTB2 EQU 33H
RSUB EQU 34H
RADD EQU 35H
TS0 EQU 36H
TBBUF EQU 37H
RD10 EQU 39H
RD23 EQU 3AH
RD0 EQU 3BH
RD1 EQU 3CH
RD2 EQU 3DH
RD3 EQU 3EH
RD4 EQU 3FH
DM0 EQU 20H.0
DM1 EQU 20H.1
ORG 0000
JMP START
ORG 000BH
JMP D1
ORG 001BH
JMP TD1
ORG 0030H
START: CALL INT
MOV IE,#10001010B
MOV TMOD,#11H
MOV TH0,#0ECH
MOV TL0,#078H
MOV R7,#0FEH
MOV TB10,#12H
MOV TB2,#9H
MOV R4,#05
MOV RD10,#2CH
MOV RD23,#1
MOV RD3,#5
SETB TR0
SETB TR1
L1: JMP L1
DD1: MOV A,@R0
JNB DM0,DD2
SWAP A
DD2: ANL A,#0FH
MOVC A,@A+DPTR
MOV P0,A
RET
D1:
MOV TH0,#0ECH
MOV TL0,#078H
MOV R0,#TB10
MOV DPTR,#TAB1
INC TS0
MOV A,TS0
CJNE A,#01,D3
MOV P2,#0FEH
MOV A,@R0
ANL A,#0FH
MOVC A,@A+DPTR
MOV P0,A
D3: CJNE A,#02,D4
MOV P2,#0FDH
MOV A,@R0
SWAP A
ANL A,#0FH
MOVC A,@A+DPTR
MOV P0,A
D4: CJNE A,#03,D5
MOV P2,#0FBH
MOV R0,#TB2
MOV A,@R0
ANL A,#0FH
MOVC A,@A+DPTR
MOV P0,A
MOV TS0,#00
D5:
DJNZ R4,D13
MOV R4,#5
MOV A,P3
ADD A,#30
CLR C
MOV TBBUF,A
MOV RTB10,#00
MOV RTB2,#00
MOV RSUB,#10H
MOV RADD,#16H
D10: CLR C
MOV 38H,A
SUBB A,RSUB
JC D12 ;跳出迴圈
D11: PUSH ACC
MOV A,RTB10
ADD A,RADD
DA A
MOV RTB10,A
MOV A,RTB2
ADDC A,#00
DA A
MOV RTB2,A
POP ACC
JMP D10
D12:
MOV RSUB,#01 ;下次減法設定的數值1
MOV RADD,#01
MOV A,38H
CPL DM1
JB DM1,D10
MOV TB10,RTB10
MOV TB2,RTB2
D13: MOV A,TBBUF
MOV B,#0AH
MUL AB
CPL A
MOV RD0,A
MOV A,B
CPL A
MOV RD1,A
CJNE A,RD0,TD3
DJNZ RD3,TD4
MOV RD3,#1
CLR TR1
RETI
TD3: MOV A,RD0
SETB TR1
TD4: RETI
TD1: MOV TH1,RD23
MOV TL1,RD10
JB P1.0,TD2
MOV RD23,#0B1H
MOV RD10,#0E0H
SETB P1.0
RETI
TD2: MOV RD23,RD1
MOV RD10,RD0
CLR P1.0
RETI
;ADC0804啟動
INT: DJNZ R7,INT
DJNZ R6,INT
SETB P2.7
INTT1: DJNZ R7,INTT1
DJNZ R6,INTT1
CLR P2.7
INTT2: DJNZ R7,INTT2
DJNZ R6,INTT2
SETB P2.7
RET
TAB1: DB 0C0H,0F9H,0A4H,0B0H,099H,092H,082H,0F8H,080H,090H
TAB2: DB 0,1,2,3,4,5,6,1,2,3,4,5,6,7,8,9
END |