;**************** Mąster Routine (burn it in Mąster 8051)*******************
mov tmod, #20h ;timer1, 8-bit auto reload, mode2.
mov th1, #-3 ;baud rate=9600bps
mov scon, #0c8h ;mode3 and tb8=1
setb tr1
mov p1, #0aah ;any data to be send to slave#1
mov p2, #55 ;any data to be send to slave#2
again:
mov sbuf, #01 ;address of sląve, this time tb8 is high because slave is to be addressed here
mov a, p1
clr tb8 ;now tb8 is cleared because we want to transmit data to the sląve
mov sbuf, a
setb tb8 ;for next sląve addressing we must make tb8=1
sjmp again
end
;**************** Sląve Routine (burn it in Sląve 8051) ******************
mov tmod, #20h ;timer1, 8-bit auto reload, mode2.
mov th1, #-3 ;baud rate=9600bps
mov scon, #0f0h ;mode3, SM2=1 and ren=1
setb tr1
back:
jnb ri, $ ;checking whether sląve has received address in above Mąster Routine
clr ri
mov a, sbuf
cjne a, #01, back
clr sm2 ;clear SM2 because address is verified and now sląve is ready to receive data
jnb ri, $ ;now checking whether sląve has received data in above Mąster Routine
clr ri
mov a, sbuf
mov p3, a
setb sm2 ;again set SM2 for next turn
sjmp back
end