Circuit Diagram:
U1 Program:
#include
sbit p=PSW^0;
unsigned char receive(void)//Receive a byte of data
{
unsigned char dat;
while(RI==0);
RI=0;//As long as the receive interrupt flag RI is not set to 1, wait until the reception is completed (RI1)
ACC=SBUF;//Store the data in the receive buffer in dat
if(RB8==P)//Odd parity
{dat=ACC;return dat;}
}
void main(void)
{
unsigned char i;
TMOD=0x20;//Timer T1 works in mode 2
SCON=0xd0;//SCON=1101 0000B, serial port working mode 1, allow reception (REN=1)
PCON=0x00;//PCON=0000 0000B, baud rate 9600
TH1=0xfd;TL1=0xfd;//Assign initial value to timer T1 according to regulations
TR1=1;//Start timer T1
REN=1;//Allow receiving
while(1)
{
for(i=0;i<9;i++)P1=receive();//Send data to P1 port
for(i=0;i<9;i++)P0=receive();//Send data to P0 port
for(i=0;i<9;i++)P2=receive();//Send data to P2 port
}
}
U2 Program:
#include
sbit p=PSW^0;
unsigned char code Tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xff};//Flowing light control code, the data is defined as a global variable
void send(unsigned char dat)//Send a byte of data to PC
{
ACC=dat;
TB8=p;
SBUF=dat;
while(TI==0);//Send and wait for
TI=0;
}
void delay(void)//delay about 150ms
{
unsigned char m,n;
for(m=0;m<200;m++)for(n=0;n<250;n++);
}
void main(void)
{
unsigned char i;
TMOD=0x20;//TMOD=0010 0000B, timer T1 works in mode 2
SCON=0xc0;//SCON=1100 0000B, serial port works in mode 3, SM2 is set to 0, multi-machine communication is not used, TB8 is set to 0
PCON=0x00;//PCON=0000 0000B, baud rate 9600
TH1=0xfd;TL1=0xfd;//assign initial value to timer T1
TR1=1;//start timer T1
while(1)
{
for(i=0;i<27;i++)//simulate detection data
{
send(Tab[i]);//send data i
delay();//send detection data once every 50ms
}
}
}
Previous article:Proteus and Keil Cx51 microcontroller simulation (serial port simplex communication)
Next article:Proteus and Keil Cx51 microcontroller simulation (serial port output expansion)
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- The silk screen is AA6B SOT23-6 package with 2.2UH inductor 3.7~4.2V boost to 5V
- Add uart6 driver
- How fast can electric vehicles be “fast charged”?
- 5G millimeter wave RF algorithm technology
- LC filter design issues in DCDC step-down circuits
- EEWORLD University Hall----RMB settlement, VAT invoice issuance and various payment methods
- [CB5654 Intelligent Voice Development Board Review] Comparison of Voice Recognition Development Boards
- C2000 Delfino MCU F28379D LaunchPad Development Kit
- [HPM-DIY] HPM SDK updated to 0.13 SD card reading and writing performance greatly improved
- Radio communication equipment manufacturing