1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

8051 Send and Receive data between 2 microcontrollers through serial port 1.0

The switch status of microcontroller 1 is send to microcontroller 2. and vice versa.

  1. sajiv jess
    The switch status of microcontroller 1 is send to microcontroller 2. and vice versa. The status are displayed over 7segment displays.

    Sponsored Links

    Circuit Diagram
    [​IMG]
    Assembly code
    Code (Text):
    1. ORG    00H
    2.     JMP    START
    3.     ORG    23H        ;
    4.     JMP    UART        ;Serial interrupt service routine
    5. ;--------------------------------
    6. START:    MOV    SP,#60H        ;Set stack
    7.     MOV    SCON,#50H    ;Set the serial port in Mode 1
    8.     MOV    TMOD,#20H    ;Timer 1 in Mode 2
    9.     MOV    TH1,#0E6H    ;Set the baud rate 1200 baud
    10.     SETB    TR1        ;Start Timer 1
    11.     MOV    IE,#10010000B    ;Interrupt Enable
    12.     MOV    30H,#0FFH    ;DIP switch setting the initial value
    13. SCAN0:    MOV    A,P1        ;I read the value of P1
    14.     CJNE    A,30H,KEYIN    ;Determine whether the value of change, change will jump to KEYIN
    15.     JMP    SCAN0        ;Rescan
    16. KEYIN:    MOV    30H,A        ;Save the new value
    17.     MOV    SBUF,A        ;Serial output
    18. WAIT:    JBC    TI,SCAN0    ;Determine whether to send the finished? Send completed the jump to SCAN0
    19.     JMP    WAIT        ;
    20. UART:    PUSH    ACC        ;Stacking
    21.     PUSH    PSW        ;
    22.     JBC    RI,L2        ;Whether the receive interrupt?
    23.     JMP    RETURN        ;
    24. L2:    MOV    A,SBUF        ;The value of the input SBUF
    25.     MOV    P2,A        ;P2 port output to
    26. RETURN:    POP    PSW        ;The stack
    27.     POP    ACC        ;
    28.     RETI
    29.     END