初学者串口通信的学习.docVIP

  • 7
  • 0
  • 约1.31千字
  • 约 6页
  • 2018-04-15 发布于河南
  • 举报
初学者串口通信的学习

#include REG52.H #define uchar unsigned char #define uint unsigned int sbit ring=P3^7; sbit CASE1=P2^0; sbit CASE2=P2^1; sbit CASE3=P2^2; sbit CASE4=P2^3; uchar se=0,re=0; 定义send 和receive uchar temp=0; 缓存区temp void wait(uint cnt) { while(--cnt); } //串口发送程序 void send(uchar se) { SBUF=se; //发送数据 while(TI == 0); TI = 0; } //串口接收程序 uchar receive(void) { re=SBUF; //接收数据 while(RI==0); RI=0; return re; } //串口初始化 void sinti(void) { SCON = 0x50; TMOD |= 0x20; TH1 = 0xFD; TR1 = 1;

文档评论(0)

1亿VIP精品文档

相关文档