8051_Serial Txd Rxd
    
    This project shows the serial transmission and reception using 8051. To simulate circuit in this project, initially activate Mixed Mode simulator from the Schematic Editor window. Simulation can be performed by selecting Run Transient analysis (Oscillograph) or Analysis -> Transient Analysis from Simulation menu. 
     
    The circuit contains an 8051 chip, Binary to 7-Segment Decoder, 7-Segment LED Display and a 
        Serial data transmitter.
     In this circuit, Port P2 is set as the output port. The Rxd pin of 8051 receives the serial data and this data can be transmitted via Txd pin.
 
     
    The Serial data transmitter generates a serial pattern. This data is received by Rxd pin of 8051. On receiving a data byte, the Receive Interrupt flag will be set to ‘1’ and the data will be stored in ‘SBUF’ register. A copy of this data will be stored in Accumulator. 
    
    On transmission of the data byte from the SBUF register, the Transmit Interrupt flag will be set to ‘1’. The accumulator content appears at output Port P2. The RI flag will again be set to ‘0’ to allow reception of another byte. The data at Port P2 is given to the Binary to 7-Segment Decoder and the result is displayed in
          7-Segment form.
   
 
    The source code written either in C or Assembly language can be viewed from the 
         code editor window 
   
 
    The program is as shown:
    
    mov SCON,#0x9a  ; Setup status of USART = Mode2
    
    received:
    jnb ri,received  ; Checking whether RI flag is set, if not set jumps to label ‘received’ (If a data byte is received on SBUF, RI flag will be set)
    
    
    mov a,sbuf  ; The data on SBUF is copied to Accumulator
    
    send:
     mov sbuf,a ; The Accumulator content is copied to SBUF.
    
    jnb ti,send  ; Checking whether TI flag is set, if not set jumps to label ‘send’ (it will set, when 8051 finishes the transfer of a byte)
     mov p2,a  ; Data stored in the Accumulator is copied to Port P2
      clr ri    ; Clear RI flag to allow the reception of another byte 
    sjmp received ; Jump to label "received"
    ret
  
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
      The source code in the 
    code editor window 
 has to be  
    compiled 
 after making any modifications 
    (editing). 
Also the code can be 
    debugged 
 during
     simulation.