simple problem...easy answer?
I am trying to connect my PC to an 8051 then connect that to another 8051 and then to another to a second PC..... so basically i want to send a character from one PC to another through the two boards.
I have two different files, one called transmit.a51 and one called receive.a51, transmit.a51 looks like:
Code:
org 8100h
rxbuf: jnb RI, rxbuf ;check for received byte from PC
clr RI ;clear RI, ready for next character
mov A, SBUF ;move character to acc from SBUF
clr p1.0 ;set p1.0 to logic 0
acall delay ;call delay
setb p1.0 ;set p1.0 to logic 1
clr p3.4 ;change ports to AUX port
clr p1.7 ;set p1.7 to logic 0
acall delay ;call delay
setb p1.7 ;set p1.7 to logic 1
mov SBUF, A ;move charcter to SBUF from acc
txbuf: jnb TI, txbuf ;send character and test for transmitted
clr TI ;clear TI ready for next character
sjmp rxbuf ;jumps back to start of program
delay: mov r3, #0ffh
loop1: mov r2, #0ffh
take: djnz r1,take
djnz r3,loop1
ret
END
and receive.a51 like this:
Code:
org 8100h
clr p3.4 ;change ports to AUX port
rxbuf: jnb RI, rxbuf ;check for received byte from TAD 1
clr RI ;clear RI, ready for next character
mov A, SBUF ;move character to acc from SBUF
clr p1.7 ;set p1.7 to logic 0
acall delay ;call delay
setb p1.7 ;set p1.7 to logic 1
clr p1.0 ;set p1.0 to logic 0
acall delay ;call delay
setb p3.4 ;change ports to primary port
setb p1.0 ;set p1.0 to logic 1
mov SBUF, A ;move charcter to SBUF from acc
txbuf: jnb TI, txbuf ;send character and test for transmitted
clr TI ;clear TI ready for next character
sjmp rxbuf ;jumps back to start of program
delay: mov r3, #0ffh
loop1: mov r2, #0ffh
take: djnz r1,take
djnz r3,loop1
ret
END
when i run them only one character is ent and then the program gets stuck. My problem is the program dosen't loop back to the start and when i try to setb p3.4 at the start of the program it freaks out!!
I think i need to loop the program to go back and check for another character after transmitting or receiving.....not sure though!!
can anyone help me please???