• 大小: 2KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-05-17
  • 语言: 其他
  • 标签: 1602  

资源简介

51串口接收字符串1602显示 自己设置结束标志

资源截图

代码片段和文件信息

#include
#include

#define uchar unsigned char
#define uint  unsigned int
#define INSTR P0

sbit rs=P2^4;
sbit rw=P2^5;
sbit en=P2^6;

//uchar code text1[]={“ this is first                “};
//uchar code text2[]={“LCD1602 program               “};
char receive[17];      //串口接收缓存
uchar bjflag;
uchar csize=0temp;
bit fan;

void delay(uint m)  //延时函数
{
uint ij;
for(i=m;i>0;i--)
for(j=1000;j>0;j--);
}

void UART_init()   //串口初始化
{
SCON=0x50;
PCON&=0x3f;
ES=1;
EA=1;
}
void time_init()     //定时器初始化
{
TMOD=0x20;
TH1=253;
TL1=253;
TR1=1;

}

void write_code(uchar cod)    //写指令
{
delay(5);
en=0;
rs=0;
rw=0;
en=1;
INSTR=cod;
_nop_();
en=0;
}

void write_data(uchar dat)   //写数据
{
delay(5);
en=0;
rs=1;
rw=0;
en=1;
INSTR=dat;
_nop_();
en=0;
rs=0;
}
void busy_check()//忙信号检测
{
      rs=0;
rw=1;
en=1;
      _nop_();
      while(INSTR&0x80)//忙信号检测关键
      {
en=0;
 _nop_();
en=1;
_nop_(); 
      }

评论

共有 条评论