串口接收一串字符在1602上显示.docx

上传人:小飞机 文档编号:3225127 上传时间:2023-03-11 格式:DOCX 页数:8 大小:37.05KB
返回 下载 相关 举报
串口接收一串字符在1602上显示.docx_第1页
第1页 / 共8页
串口接收一串字符在1602上显示.docx_第2页
第2页 / 共8页
串口接收一串字符在1602上显示.docx_第3页
第3页 / 共8页
串口接收一串字符在1602上显示.docx_第4页
第4页 / 共8页
串口接收一串字符在1602上显示.docx_第5页
第5页 / 共8页
亲,该文档总共8页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《串口接收一串字符在1602上显示.docx》由会员分享,可在线阅读,更多相关《串口接收一串字符在1602上显示.docx(8页珍藏版)》请在三一办公上搜索。

1、串口接收一串字符在1602上显示#include<reg52.h>#include<intrins.h>#define uchar unsigned char#define uint unsigned int#define INSTR P0sbit rs=P24;sbit rw=P25;sbit en=P26;/uchar code text1= this is first ;/uchar code text2=LCD1602 program ;char receive17; /串口接收缓存uchar b,j,flag;uchar csize=0,temp;bit fan;vo

2、id delay(uint m) /延时函数uint i,j;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

3、;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_; void init1602/ 1602 初始化delay(15);write_code(0x38);write_code(0x38);write_code(0x38);busy_check;write_code(0x0c);busy_check;write_code(0x06);busy_check;write_code(0x01);

4、void write_byte(uchar x,bit y,uchar byte) /想指定地址写入数据x&=0x0f;if(y)x+=0x40;x+=0x80;busy_check;write_code(x);busy_check;write_data(byte);void write(uchar add,bit y,uchar *first)uchar a;a=add;for(j=0;j<b;j+)write_byte(a+,y,*(first+);b=0;a=0;void mainUART_init;time_init;init1602;while(1)if(flag=1)flag=0;write(0,fan,receive);if(fan)fan=0;void UATR interrupt 4if(RI)ES=0;temp=SBUF;receivecsize=temp;/csize+;if(receivecsize+=.)b=csize-1;flag=1;csize=0;if(temp=#)fan=1;csize=0;if(csize=17)csize=0;b=16;RI=0;ES=1;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号