《51单片机串口通信-232通信-485通信-程序.doc》由会员分享,可在线阅读,更多相关《51单片机串口通信-232通信-485通信-程序.doc(4页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、.51单片机串口通信,232通信,485通信,程序代码1:232通信#include#define uchar unsigned char#define uint unsigned intuchar flag,a,i;uchar code table=i get;void init()TMOD=0X20;TH1=0XFD;TH0=0XFD;TR1=1;REN=1;SM0=0;SM1=1;EA=1;ES=1;void main()init();while(1)if(flag=1)ES=0;for(i=0;i6;i+)SBUF=tablei;while(!TI);TI=0;SBUF=a; whil
2、e(!TI);TI=0;ES=1;flag=0;void ser() interrupt 4RI=0;a=SBUF;flag=1;代码2:485通信#include#include1602.h#define uchar unsigned char #define uint unsigned int unsigned char flag,a,i;uchar code table=i get ;void init()TMOD=0X20;TH1=0Xfd;TL1=0Xfd;TR1=1;REN=1;SM0=0;SM1=1;EA=1;ES=1;void main()init_1602();init();while(1)if(flag=1)display(0,a);void ser() interrupt 4RI=0;a=SBUF;flag=1;实用文档.