三个单片机串行通信,1号从机和2号从机在p1口处个接八个按键, 主机p0口有八个灯,另外主机在p1.0和p1.1有两个按键,第一个按键按下接通一号从机,当1号从机有按键按下时候,主机p0对应的灯亮,同理同理主机第2个按键按下 接通2号从机,当2号从机有按键按下时候,主机p0对应的灯亮 程序如下,在protues 里仿真一点没反应,请教下谁能帮我看下程序错在哪里怎么改? 麻烦了 谢谢!! 主机: ORG 00H AJMP MAIN ORG 30H MAIN: MOV SCON,#98H START: MOV A,P1 CJNE A,#0FFH,M1 SJMP START M1: CJNE A,#0FEH,M2 SJMP L1 M2: CJNE A,#0FDH,START SJMP L2 L1: MOV SBUF,#01H JBC TI,S1 SJMP L1 L2: MOV SBUF,#02H JBC TI,S2 SJMP L2 S1: JBC RI,WT1 SJMP S1 S2: JBC RI,WT2 SJMP S2 WT1: MOV A,SBUF XRL A,#01H JZ RIGHT SJMP WT1 WT2: MOV A,SBUF XRL A,#02H JZ RIGHT SJMP WT2 RIGHT: CLR TB8 JBC RI,REC SJMP RIGHT REC: MOV A,SBUF MOV P0,A AJMP RIGHT END 从机: ORG 00H AJMP MAIN ORG 30H MAIN: MOV SCON,#0B0H MOV 30H,#0FFH M1: JBC RI,S1 SJMP M1 S1: MOV A,SBUF XRL A,#02H JNZ M1 MOV SBUF,#02H MOV P0,#0FDH WT: JBC TI,S2 SJMP WT S2: JNB RB8,RIGHT SETB SM2 SJMP M1 RIGHT:MOV A,P1 CJNE A,30H,SENT JMP RIGHT SENT: MOV 30H,A MOV SBUF,A WAIT: JBC TI, RIGHT SJMP WAIT END
|