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 Interconnecting 2 microcontrollers through serial port 1.0

Interconnecting 2 microcontrollers through serial port

  1. sajiv jess
    Interconnect 2 microcontroller through serial port.
    Switches are connected to one of the microcontroller and 7segment display is connected to the other microcontroller.

    Sponsored Links

    Circuit Diagram

    [​IMG]
    Assembly Code for microcontroller 1
    Code (Text):
    1. ORG    00H
    2.     JMP    START
    3. START:    MOV    SP,#60H        ;Set stack
    4.     MOV    SCON,#50H    ;Set the serial port in Mode 1
    5.     MOV    TMOD,#20H    ;Timer 1 in Mode 2
    6.     MOV    TH1,#0E6H    ;Set the baud rate 1200 baud
    7.     SETB    TR1        ;Start Timer 1
    8.     MOV    30H,#0FFH    ;DIP switch setting the initial value
    9. SCAN0:    MOV    A,P1        ;I read the value of P1
    10.     CJNE    A,30H,KEYIN    ;Determine whether the value of change, change will jump to KEYIN
    11.     JMP    SCAN0        ;Rescan
    12. KEYIN:    MOV    30H,A        ;Save the new value
    13.     MOV    SBUF,A        ;Serial output
    14. WAIT:    JBC    TI,SCAN0    ;Determine whether to send the finished? Send completed the jump to SCAN0
    15.     JMP    WAIT        ;
    16.     END
    Assembly Code for microcontroller 2
    Code (Text):
    1. ORG    00H
    2.     JMP    START
    3. START:    MOV    SP,#60H        ;Set stack
    4.     MOV    SCON,#50H    ;Set the serial port in Mode 1
    5.     MOV    TMOD,#20H    ;Timer 1 in Mode 2
    6.     MOV    TH1,#0E6H    ;Set the baud rate 1200 baud
    7.     SETB    TR1        ;Start Timer 1
    8. SCAN0:    JB    RI,UART        ;Whether the received data, there are jump UART
    9.     JMP    SCAN0        ;
    10. UART:    MOV    A,SBUF        ;Will receive the data read
    11.     MOV    P2,A        ;Export to P2
    12.     CLR    RI        ;RemoveRI=0
    13.     JMP    SCAN0        ;Jump to SCAN0
    14.     END