用两片8255扩展程序如下: ORG 00H JMP START ORG 30H START: CLR P3^2 CALL DELAY SETB P3^2 AD8255 EQU 0F0FFH ;A8255 状态/命令口地址 AD8255A EQU 0C0FFH ;A8255 PA 口地址 AD8255B EQU 0D0FFH ;A8255 PB 口地址 AD8255C EQU 0E0FFH ;A8255 PC 口地址 BD8255 EQU 0F1FFH ;B8255 状态/命令口地址 BD8255A EQU 0C1FFH ;B8255 PA 口地址 BD8255B EQU 0D1FFH ;B8255 PB 口地址 BD8255C EQU 0EFFH ;B8255 PC 口地址 ;--------------------------------------------------------- KOUT: MOV DPTR,#AD8255 MOV A,#80H ;置A8255状态,方式0,PA,PB,PC口输出 MOVX @DPTR,A CALL DELAY MOV DPTR,#AD8255A MOV A,#00H MOVX @DPTR,A CALL DELAY MOV DPTR,#AD8255B MOV A,#00H MOVX @DPTR,A CALL DELAY MOV DPTR,#AD8255C MOV A,#00H MOVX @DPTR,A CALL DELAY MOV DPTR,#BD8255 MOV A,#80H ;置B8255状态,方式0,PA,PB,PC口输出 MOVX @DPTR,A MOV DPTR,#BD8255A INC R0 MOV A,@R0 MOVX @DPTR,A CALL DELAY MOV DPTR,#BD8255B INC R0 MOV A,@R0 MOVX @DPTR,A CALL DELAY MOV DPTR,#BD8255C INC R0 MOV A,@R0 MOVX @DPTR,A CALL DELAY SJMP KOUT DELAY: MOV R6,#0ffH ;延时子程序 DELAY1: MOV R7,#0ffH DJNZ R7,$ DJNZ R6,DELAY1 RET
end
只是清了下0,就乱输出,会是怎样的原因呢? |