当前位置:网站首页>Realization of data transmission between a and B computers by using single chip microcomputer serial port
Realization of data transmission between a and B computers by using single chip microcomputer serial port
2022-06-24 05:51:00 【Distant stars】
subject : The serial port of single chip microcomputer is used to realize the data transmission between machine a and machine B .
requirement :
- ① Machine a continuously sends 0-F, Co recording 16 Characters , And display it on the nixie tube ;
- ② Machine B receives the content of machine a and sends it back after displaying it with nixie tube ;
- ③ After receiving the content returned by machine B, machine a compares it with the current content , If consistent, send the next ;
- ④ Crystal vibration is 11.0592Mhz, The baud rate of data communication is 2400.
1、 Virtual circuit diagram
2、 To achieve the effect of
3、 Related codes
- ① Transmitter section
#include<reg51.h>
#define uchar unsigned char
char code map[]={
0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7c,0x39,0x5e,0x79,0x71
};
void delay(unsigned int time){
unsigned int j = 0;
for(;time>0;time--)
for(j=0;j<125;j++);
}
void main(void){
uchar counter=0; // Define counters
TMOD=0x20; //T1 Timing mode 2
TH1 = TL1 = 0xf4;//2400b/s
PCON=0; // Baud rate does not double
SCON = 0X50; // Serial port mode 1,TI and RI Zero clearing , Allowable convergence
TR1=1; // start-up TI
while(1){
SBUF = counter;// Send a contact signal
while(TI==0); // Wait for the send to complete
TI=0; // clear TI Sign a
while(RI==0); // Wait for machine B to answer
RI=0;
if(SBUF == counter){ // If the return value is the same as the sending value , Organize new data
P2 = map[counter];// Show sent values
if(++counter>15) counter=0;// Correct the counter value
delay(1000);
}
}
}- ② Receiver part
#include<reg51.h>
#define uchar unsigned char
char code map[]={
0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7c,0x39,0x5e,0x79,0x71
};
void main(void){
uchar receive; // Define the receive buffer
TMOD=0x20; //TI Timing mode 2
TH1=TL1=0xf4; //2400b/s
PCON=0; // Baud rate does not double
SCON=0x50; // Serial port mode 1,TI and RI Zero clearing , Allow to accept
TR1=1; // start-up TI
while(1){
while(RI==1){ // Wait for reception to complete
RI = 0; // clear RI Sign a
receive = SBUF; // Get the received value
SBUF = receive; // The result is returned to the host
while(TI==0); // Wait for the end of sending
TI = 0; // clear TI Sign a
P2 = map[receive]; // Displays the received value
}
}
}If there is any deficiency , Please leave a message in the comments area or send me a private letter , I will add .
Thank you for your support , I hope you can praise , Focus on , Collection , Three times with one click .
author : Stars in the distance CSDN:https://blog.csdn.net/qq_44921056
边栏推荐
- How enterprises overcome the data security barrier with the imminent implementation of the new law | interview with think tank on industrial security concept
- Adobe international certification wants to design! Understanding the style guide is your best introduction design
- How to register the company domain name mailbox? Is the operation process complicated
- "Adobe international certified" graphic designer! How to break through the creative barrier and gain both fame and wealth?
- How to file a personal domain name? What are the benefits of domain name filing?
- Interpretation of Cocos creator source code: siblingindex and zindex
- Spirit breath development log (7)
- Groovy script engine practice in complex and changeable scenarios
- Why should the domain name be filed? What materials are needed for the filing of enterprise domain names?
- Kubernetes Chapter 1: Foundation
猜你喜欢
随机推荐
How to build a website after registering a domain name? Do you need maintenance later?
How to register domain name and web address? What is the domain name and URL?
[Tencent cloud] enterprise micro marketing, private domain traffic value growth and operation efficiency improvement
Tencent security operation center integrates ueba capabilities to help enterprises ensure internal network security
To create a high-quality geek for human beings, cloud + community starts the competition "discovery plan"
Havip+keepalived high availability building
Is the prospect of cloud computing in the security industry worth being optimistic about?
Sub process call - process arrangement in complex O & M scenarios
His secret script of hard technology investment
How to apply for a company domain name? Does it cost money to apply for a company domain name?
Tencent (t-sec NTA) was listed in the report emerging trends: best use cases for network detection and response recently released by Gartner
Inferior administrator and black heart Haikang
How to build a website with a domain name? What steps need to be taken?
Data warehouse data processing DB basic concept analysis and understanding OLAP OLTP hatp similarities and differences MPP architecture
Progress update | optimization and upgrading of shard nodes
"Yi Jian Xing" was "Internet stormed". What countermeasures does the game company have other than "rather be broken jade"?
How to use a Chinese domain name? Would you prefer a Chinese domain name or an English domain name?
What are the advantages of building a private cloud platform?
MySQL optimization
How does the company domain name come from? What kind of domain name is a good domain name