一个单片机控制三个单片机通讯.docVIP

  • 7
  • 0
  • 约2.38千字
  • 约 6页
  • 2020-11-19 发布于湖北
  • 举报
总图 从机 主机 从机的程序 #ifndef _receive_data_h #define _receive_data_h #includereg52.h #define uchar unsigned char #define uint unsigned int uchar buf; uchar addr; sbit P23=P2^3; #endif #includereceive_data.h void delay(uint t) { uint i; while(t--) { for(i=0;i125;i++); } } uchar recvdata() { while(!RI); if(RB8==1) return 0xee; buf=SBUF; RI=0; return 0; } void init() { TMOD=0x20; TH1=250; TL1=250; TR1=1; PCON=0x80; SCON=0xd0; REN=1; //当REN等于0时,禁止接收数据 } void main() { uchar i=0; uchar tmp=0xff; P1=0xff; addr=P10x0f; P23=1; init(); EA=1; while(1) { SM2=1; while(tmp!=ad

文档评论(0)

1亿VIP精品文档

相关文档