I am new in microcontroller world, want to interface two PC's using MAX232 and 89c51 microcontroller for Simplex Serial port communication and Bi-directional communication.
However, Simplex communication is working through microcontroller on hyper terminal, what should be the code to interface Bi-Directionally.
Thanks in advance.
Bi-Directional Code in assembly for 8051 Micro-controller.
I have the Simplex Serial communication code for assembly language...its very simple
Simplex Serial Communication code to receive data from Serial Buffer and send it to Port 2.
Baud-rate:
mov scon,#50h ; Initialize serial communication
mov TMOD,#20h ; Timer 1 Mode 2
mov TH1,#0fdh ; For 9600 baud-rate
setb TR1 ; Start Timer 1
ret
HERE:
JNB RI,HERE ; Wait for char to come in
MOV A,SBUF ; Save incoming byte in Register A
MOV P2,A ; Move the contents of A at P2
CLR RI ; Get ready to receive next byte
SJMP HERE ; Keep getting data
END
This Code is for Other Device that Receive Data from Port 2 and Send it to SBUF
MOV TMOD,#20H ; Timer 1, Mode 2 (Auto-Reload)
MOV TH1,#0FDH ; Baud-Rate = 9600
MOV SCON,#50H ; 8-bit, 1 stop bit, REN enabled
SETB TR1 ; Start Timer 1
AGAIN:
MOV A,P2 ; Receive contents from P2 to A
ACALL TRANS
SJMP AGAIN ; Keep doing it
;-------Serial Data Transfer Subroutine
TRANS:
MOV SBUF,A ; Move contents of A in SBUF
HERE:
JNB TI,HERE ; Wait for last bit to transfer
CLR TI ; Get ready for next byte
RET
END