串口通信课程设计
代码说明:
#include //52系列单片机头文件#define uchar unsigned char#define uint unsigned int sbit cs1=P2^3; //数码管段选信号sbit cs2=P2^2; //数码管段选信号sbit cs3=P2^1; //数码管段选信号sbit cs4=P2^0; //数码管段选信号sbit RE=P1^6; //低电平收数据,高电平发数据sbit DE=P1^7; //低电平收数据,高电平发数据sbit key0=P1^0; //主机用两个拨码开关sbit key1=P1^1; //主机用两个拨码开关uchar show_code[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x83,0xf8,0x80,0x98}; //数字0-9的显示码,更改数码管显示程序。uchar temp1=0,temp2=0;uchar count=0,sum=0;//void delayms(uint); //延时函数声明//void decide (void);void send_byte(uchar t) //发送一个字节 发送一个数据后立马变成收数据的状态{ RE=1; //高电平发 DE=1; //高电平发 ES=0; SBUF=t; while(!TI); TI=0;ES=1; RE=0; //低电平收 DE=0; //低电平收}void delayms(uint xms) //延时
下载说明:请别用迅雷下载,失败请重下,重下不扣分!