刚刚接触单片机的学习,在尝试制作智能电子密码锁仿真,但在调试过程出现了问题,求大神帮忙解决问题!
要求的效果是,输入123456后确定,LED亮表示正确
出现的问题是,可以输入数字,但按下确定键后无论密码正确与否,LED灯都不亮。
以下是电路图和源程序设计
ORG 00H MOVR5,#00H MOVR7,#00H DJNZ R7,$ MOVR7,#10H MOVR6,#06H MOVR1,#35H L1: MOV A,R7 MOVDPTR,#TABLE MOVCA,@A+DPTR MOV @R1,A DEC R1 INC R7 DJNZ R6,L1 START: ORL P2,#0FFH MOVR4,#06H MOVR0,#40H CLEAR: MOV @R0,#00H INC R0 DJNZR4,CLEAR L2: MOVR3,#0F7H MOVR1,#00H L3: MOV A,R3 MOV P1,A MOV A,P1 MOV R4,A SETB C MOVR5,#04H L4: RLC A JNC KEYIN INC R1 DJNZR5,L4 CALL DISP MOV A,R3 SETB C RRC A MOV R3,A JC L3 JMP L2 KEYIN: MOV A,R1 XRLA,#0BH JZ X3 MOV A,R1 XRLA,#0FH JZ X4 MOVR7,#10 D1: MOV R6,#24 DJNZ R6,$ DJNZR7,D1 D2: MOV A,P1 XRL A,R4 JZ D2 MOV A,R1 MOV DPTR,#TABLE MOVCA,@A+DPTR MOV R7,A XRLA,#0AH JZ SET0 MOV A,R7 XRLA,#0BH JZ START MOV A,R7 XRLA,#0CH JZ L2 MOV A,R7 XRLA,#0DH JZ L2 MOV A,R7 XCH A,40H XCH A,41H XCH A,42H XCH A,43H XCH A,44H XCH A,45H CALL DISP JMP L2 X3: JMP DISP2 X4: JMP COMP DISP:MOV R0,#45H DISP1: MOV A,@R0 ADDA,#50H MOV P0,A CALLDELAY DEC R0 MOV A,@R0 ADDA,#40H MOV P0,A CALLDELAY DEC R0 MOV A,@R0 ADDA,#30H MOV P0,A CALLDELAY DEC R0 MOV A,@R0 ADDA,#20H MOV P0,A CALLDELAY DEC R0 MOV A,@R0 ADDA,#10H MOV P0,A CALLDELAY DEC R0 MOV A,@R0 ADDA,#00H MOV P0,A CALLDELAY RET SET0: MOVR2,#06H MOVR0,#40H MOVR1,#30H E1: MOV A,@R0 XCH A,@R1 INC R0 INC R1 DJNZR2,E1 CALLDELAY E2: JMP START COMP: MOVR1,#45H MOVR0,#35H MOVR2,#06H C1: MOV A,@R1 XRL A,@R0 JNZ C3 DEC R1 DEC R0 DJNZR2,C1 CLR P2.0 MOVR2,#200 C2: MOVR6,#248 DJNZ R6,$ DJNZR2,C2 C3: INC R5 MOVA,R5 MOVR5,A CJNE R5 ,#03H,C4 CLR P2.1 MOVR5,#00H C4: JMP START DISP2: MOV R0,#35H CALL DISP MOV A,P1 XRL A,R4 JZ DISP2 CALLDELAY JMP START DELAY: MOV R7,#C3 D3: MOVR6,#248 DJNZR7,D3 RET ORG 300H TABLE: DB 01H,02H,03H,0CH DB 04H,05H,06H,0DH DB 07H,08H,09H,0EH DB 0AH,00H,0BH,0FH DB 01H,02H,03H,04H,05H,06H END
|