22862827
|
分享:
▼
x0
|
[8051]8051.声控程式的问题
想问1下下面是我声控程式不过我用程式检查后有182个错误点他她都指向 OUTPUT CONTROL VIN DIV等地方不过小弟我也不知道错在哪下面是我的程式码请大家帮我抓错1下 另外这是我在执行的时候错误的图 恳请各位高手的帮忙.. PKH EQU 30H PKL EQU 31H COUNT EQU 32H SECT EQU 33H SUM EQU 34H PK0 EQU 40H OUTPUT REG P2 CONTROL REG P1 VIN REG P3.4 OFF EQU 0FFH CNT EQU 1 SCT EQU 20 DIV EQU -30000 ORG 00H JMP MAIN ORG 0BH JMP TIMER0 ORG 1BH JMP TIMER1 MAIN: SETB VIN MOV CONTROL,#11111100B MOV OUTPUT,#0C0H MOV TMOD,#15H SETB EA SETB ET0 SETB ET1 SAMP: MOV SECT,#SCT MOV R0,#PK0 MOV R2,#0 JB VIN,$ WAIT: SETB VIN JB VIN,SAMP INC R2 CJNE R2,#30,WAIT START: MOV TH0,#0 MOV TL0,#0 MOV TH1,#>DIV MOV TL1,#<DIV MOV COUNT,#CNT SETB TR0 SETB TR1 JNB F0,$ CLR F0 CJNE R0,#PK0,CONT MOV A,THO CJNE A,#0,SAMP MOV A,TLO ADD A,#252 JC CONT MOV CONTROL,#11111000B MOV OUPUT,#0C0H JMP SAMP CONT: MOV A,TLO MOV @R0,A INC R0 DJNZ SECT,START MOV CONTROL,#OFF CALL DELAY2 VR: M .. 访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容
|
|
x0
[楼 主]
From:台湾中华电信
| Posted:2006-05-13 12:09 |
|
|
cmovies
|
分享:
▲
▼
你有很多应该写数字 0 写成字母 O, 还有 > 或者 < 是 X8051 的指令 DIV 为指令不可当成变数 复制程式
PKH EQU 30H
PKL EQU 31H
COUNT EQU 32H
SECT EQU 33H
SUM EQU 34H
PK0 EQU 40H
OUTPUT EQU P2
CONTROL EQU P1
VIN EQU P3.4
OFF EQU 0FFH
CNT EQU 1
SCT EQU 20
DIV1 EQU -30000
ORG 00H
JMP MAIN
ORG 0BH
JMP TIMER0
ORG 1BH
JMP TIMER1
MAIN:
SETB VIN
MOV CONTROL,#11111100B
MOV OUTPUT,#0C0H
MOV TMOD,#15H
SETB EA
SETB ET0
SETB ET1
SAMP:
MOV SECT,#SCT
MOV R0,#PK0
MOV R2,#0
JB VIN,$
WAIT: SETB VIN
JB VIN,SAMP
INC R2
CJNE R2,#30,WAIT
START:
MOV TH0,#0
MOV TL0,#0
MOV TH1,#HIGH DIV1
MOV TL1,#LOW DIV1
MOV COUNT,#CNT
SETB TR0
SETB TR1
JNB F0,$
CLR F0
CJNE R0,#PK0,CONT
MOV A,TH0
CJNE A,#0,SAMP
MOV A,TL0
ADD A,#252
JC CONT
MOV CONTROL,#11111000B
MOV OUTPUT,#0C0H
JMP SAMP
CONT:
MOV A,TL0
MOV @R0,A
INC R0
DJNZ SECT,START
MOV CONTROL,#OFF
CALL DELAY2
VR:
MOV A,043H
ADD A,044H
ADD A,045H
MOV SUM,A
ADD A,#229
JC VR1
;A<27
MOV CONTROL,#11110000B
MOV OUTPUT,#0BFH
JMP SAMP
VR1:
MOV A,SUM
ADD A,#217
JC VR2
MOV A,041H
ADD A,042H
JC VR12
ADD A,043H
JC VR12
ADD A,044H
JC VR12
ADD A,045H
JC VR12
ADD A,046H
JC VR12
ADD A,047H
JC VR12
ADD A,048H
JC VR12
ADD A,49H
JC VR12
ADD A,4AH
JC VR12
ADD A,#81
JC VR12
MOV A,#5
MOV DPTR,#LEDTABLE
MOVC A,@A+DPTR
MOV CONTROL,#11111110B
MOV OUTPUT,A
JMP SAMP
VR12:
MOV A,#1
MOV DPTR,#LEDTABLE
MOVC A,@A+DPTR
MOV CONTROL,#11111110B
MOV OUTPUT,A
JMP SAMP
VR2:
MOV A,SUM
ADD A,#184
JC VR3
MOV A,48H
ADD A,49H
ADD A,4AH
ADD A,#211
JC VR4
MOV A,#4
MOV DPTR,#LEDTABLE
MOVC A,@A+DPTR
MOV CONTROL,#11111110B
MOV OUTPUT,A
JMP SAMP
VR3:
MOV A,SUM
ADD A,#157
JC VR32
MOV A,#3
MOV DPTR,#LEDTABLE
MOVC A,@A+DPTR
MOV CONTROL,#11111110B
MOV OUTPUT,A
JMP SAMP
VR32:
MOV A,#1
MOV DPTR,#LEDTABLE
MOVC A,@A+DPTR
MOV CONTROL,#11111110B
MOV OUTPUT,A
JMP SAMP
VR4:
MOV A,41H
ADD A,42H
ADD A,#226
JC VR42
MOV A,#1
MOV DPTR,#LEDTABLE
MOVC A,@A+DPTR
MOV CONTROL,#11111110B
MOV OUTPUT,A
JMP SAMP
VR42:
MOV A,#2
MOV DPTR,#LEDTABLE
MOVC A,@A+DPTR
MOV CONTROL,#11111110B
MOV OUTPUT,A
JMP SAMP
TIMER0:
RETI
TIMER1:
MOV TH1,#HIGH DIV1
MOV TL1,#LOW DIV1
DJNZ COUNT,RETIME
CLR TR0
CLR TR1
SETB F0
RETIME:
RETI
DELAY:
MOV R5,#10
DE1:
MOV R6,#248
DJNZ R6,$
DJNZ R5,DE1
RET
DELAY2:
MOV R5,#5
DL1:
MOV R6,#200
DL2:
MOV R7,#250
DJNZ R7,$
DJNZ R6,DL2
DJNZ R5,DL1
RET
LEDTABLE:
DB 11000000B
DB 11111001B
DB 10100100B
DB 10110000B
DB 10011001B
DB 10010010B
DB 10000010B
DB 11011000B
DB 10000000B
DB 10010000B
DB 00001000B
DB 00000011B
DB 01000110B
DB 00100001B
DB 00000110B
DB 00001110B
VTABLE:
DB 0,0,0,0,0,0,0,0,1,1
DB 1,1,1,1,1,0,2,2,2,2
DB 2,0,3,3,3,3,3,3,0,4
DB 4,4,4,0,5,5,5,5,5,5
DB 5,0,0,0,0,0,0,0,0,0
END
|
|
x0
[3 楼]
From:台湾中华电信
| Posted:2006-05-17 23:35 |
|
|
|