use USART Serial communication , Baud rate is 9600, A single chip microcomputer sends digital signal ( The last two of their student numbers )
  A single chip microcomputer receiving , And the received number is displayed by digital tube .
  Need source code and simulation diagram can add me QQ2142686503
  Receiving part of the program :
  Serial port receiving 
#include"usart.h" unsigned char buf; // The header file is a declaration , Here is the definition  bit flag; // Display sign  void 
UsartInit(void) //9600bps @11.0592MHz { PCON &= 0x3F; // Enable SM0 SMOD=0  When reset 0 SCON 
= 0x50; // Mode one 8 position   No double  SM0 SM1 SM2 REN( Accept control bit ) TB8 RB8 TI RI  AUXR &= 0xBF; 
// timer 1 The clock is Fosc/12, Namely 12T AUXR &= 0xFE; // Serial port 1 Select timer 1 Is the baud rate generator  TMOD &= 0x0F; // Clear timer 1 Mode bit 
 TMOD|= 0x20; // Set timer 1 by 8 Bit auto reload mode  TL1 = 0xFD; // Setting the initial value of timing  TH1 = 0xFD; // Set timer reset value  ET1 
= 0; // inhibition timer  1 interrupt  TR1 = 1; // Start timer 1 EA = 1; ES = 1; // Allow serial port interrupt  } void Usart() 
interrupt4 { buf = SBUF; // Read buffer value   flag = 1; // Open the display after accepting once  ES = 0; // Turn off serial interrupt  RI = 0
; // Clear serial accept flag bit  // ES = 1; } 
 Display numeric functions 
#include"display.h" #include"delay.h" unsigned char code table[]={0x00 , 0x01 ,
0x02 , 0x03 , 0x04 , 0x05 ,0x06 ,0x07,0x08,0x09}; //0----9 void Display(unsigned
char i) // Digital display  { static unsigned char ge, shi, mode; if(mode!=i) 
// When the value does not change , Removal calculation , One less time while Cycle time  { ge = i % 10; shi = i / 10; mode = i; // Record the last value  } P2
= table[ge] + 0xf0; // data + Turn off bit selection  delay(1); P2 &= 0xdf; // Open bit selection   Common cathode low level bright  delay(5); 
// Full display  P2 |= 0xf0; // Shadow elimination  delay(1); P2 = table[shi] + 0xf0; //P2 Position selection   Individual position P2^7  Ten P2^6 
delay(1); P2 &= 0xef; delay(5); } 
 Principal function 
#include"reg52.h" #include"usart.h" #include"display.h" #include"delay.h" void 
main(void) { UsartInit(); while(1) { while(flag) // Only after receiving the data can it be displayed  { Display(buf); 
// Display received value  delay(5); } } } 
 Send MCU function 
void UART_SendBit(unsigned char Data) // send data  { SBUF=Data; // write SUBF instructions , Start sending  while(
!TI); // Send complete ,TI Place 1, Request interrupt ( Non disruptive function ) TI=0; // Manual reset  } void UsartInit(void) 
//[email protected] { PCON &= 0x3F; // Enable SM0 SMOD=0  When reset 0  The baud rate is not doubled  SCON = 0x50; 
//8 Bit data , Variable baud rate  SM1 SM2 REN( Accept control bit ) TB8 RB8 TI RI AUXR &= 0xBF; 
// timer 1 The clock is Fosc/12, Namely 12T AUXR &= 0xFE; // Serial port 1 Select timer 1 Is the baud rate generator  TMOD &= 0x0F; // Clear timer 1 Mode bit 
 TMOD|= 0x20; // Set timer 1 by 8 Bit auto reload mode  TL1 = 0xFD; // Setting the initial value of timing  TH1 = 0xFD; // Set timer reset value  ET1 
= 0; // inhibition timer  1 interrupt  TR1 = 1; // Start timer 1 } 
Technology