当前位置:网站首页>51 serial communication (on)
51 serial communication (on)
2022-08-09 05:38:00 【Fate gathering 654】
51 can realize the communication between the single-chip microcomputer and the computer, that is, control the single-chip microcomputer to realize some functions through the data transmission between the two
There is already a small tool called Serial Assistant in stc to help us realize serial communication

The receiving area is used to receive the data sent by the single-chip microcomputer to the computer, and the sending area is used for the computer to send the data to the single-chip computer.
The following is the related knowledge of serial port. For the specific content, you can watch the teaching video of Jiangxi Association for Automation 51 MCU at station B to understand





void UART_SendByte(unsigned char Byte);
void UART_Init();
Here we need to write two functions to realize the initialization of the serial port and the function of the computer to receive the data sent by the microcontroller
void UART_SendByte(unsigned char Byte){SBUF=Byte;while(TI==0){TI=0;}}void UART_Init(){SCON=0x40;PCON=0x80;TMOD &= 0x0F;TMOD |= 0x20;TL1=0xF4;TH1=0xF4;TF0=0;TR1=1;ET1=0;EA=1;PT0=0;}Main function
unsigned char Sec;void main(){UART_Init();while(1){UART_SendByte(Sec);Sec++;Delay(1000);}}This process is actually still sent by the computer to the microcontroller and then sent back to the computer by the microcontroller, so the effect of the operation is that the computer receives the binary number returned by the microcontroller and increases from 00

Then the computer sends data to the microcontroller and I will explain it next time
边栏推荐
猜你喜欢
随机推荐
22-08-08 西安 尚医通(04)MongoDB命令、MongoTemplate、MongoRepository
JDBC_PreparedStatement预编译对象
[Daily Training--Tencent Featured 50] 7. Integer Reversal
shell函数
PWM输出模块PCA9685
command,shell,raw,script模块的作用和区别,file、copy、fetch、synchronize的应用
3.3V控制输出5V的方法
p67 mixin 混入/混合:两个组件共享一个配置
废品回收小程序、APP UNIAPP开发带有用户端和回收员端
shell function
Software testing method is introduced in detail
STM32之vl53l0x读取距离
数据库事务&锁机制
MATLAB图像处理入门
10.LoadRunner2022社区版安装
步进电机驱动的使用及程序
打开数字时代的门槛,元宇宙NFT商城开发解决方案
Eureka-Server------单节和集群的搭建
C语言之内存函数
deploy发布的jar包中文乱码







![[mysql database] the use of mysql database](/img/5a/eee7cf35dc5caa0123d1cbbbf4c0ba.png)

