欢迎来到天天文库
浏览记录
ID:37469595
大小:313.50 KB
页数:7页
时间:2019-05-24
《rs485通讯程序接收0123456789,只接收不发送,使用LM1602液晶显示》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、rs485通讯程序接收0123456789,只接收不发送,使用LM1602液晶显示2008-12-0719:45#include#include#include#include//液晶为JDH162A1602液晶16*2//以下宏定义语句可根据实际情况更改#definedataportPORTB#definedatapinPINB#definedataddrDDRB#defineconportP
2、ORTA#defineconddrDDRA#definerwPA5#definersPA6#defineePA4unsignedcharstr1[]="Waiting.........";volatileintnum;//中断接收函数ISR(USART_RXC_vect){writelocatechar(num,0,UDR);num++;};unsignedcharisbusy(void){unsignedchartmp;conport&=~(1<3、taddr=0x00;conport&=~(1<4、=(1<5、=(1<6、=~(1<7、(1<8、=(1<9、C=_BV(URSEL)10、0x06;UBRRL=ubbrl;//setbaudratelo//UBRRH=ubbrh;//setbaudratehiUCSRB=0x90;}voidwritedata(unsignedcharcom,unsignedcharbusy_flag){if(busy_flag) while(isbusy()!=0);dataddr=0xff;conport&=~(1<11、=12、(1<13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
3、taddr=0x00;conport&=~(1<4、=(1<5、=(1<6、=~(1<7、(1<8、=(1<9、C=_BV(URSEL)10、0x06;UBRRL=ubbrl;//setbaudratelo//UBRRH=ubbrh;//setbaudratehiUCSRB=0x90;}voidwritedata(unsignedcharcom,unsignedcharbusy_flag){if(busy_flag) while(isbusy()!=0);dataddr=0xff;conport&=~(1<11、=12、(1<13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
4、=(1<5、=(1<6、=~(1<7、(1<8、=(1<9、C=_BV(URSEL)10、0x06;UBRRL=ubbrl;//setbaudratelo//UBRRH=ubbrh;//setbaudratehiUCSRB=0x90;}voidwritedata(unsignedcharcom,unsignedcharbusy_flag){if(busy_flag) while(isbusy()!=0);dataddr=0xff;conport&=~(1<11、=12、(1<13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
5、=(1<6、=~(1<7、(1<8、=(1<9、C=_BV(URSEL)10、0x06;UBRRL=ubbrl;//setbaudratelo//UBRRH=ubbrh;//setbaudratehiUCSRB=0x90;}voidwritedata(unsignedcharcom,unsignedcharbusy_flag){if(busy_flag) while(isbusy()!=0);dataddr=0xff;conport&=~(1<11、=12、(1<13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
6、=~(1<7、(1<8、=(1<9、C=_BV(URSEL)10、0x06;UBRRL=ubbrl;//setbaudratelo//UBRRH=ubbrh;//setbaudratehiUCSRB=0x90;}voidwritedata(unsignedcharcom,unsignedcharbusy_flag){if(busy_flag) while(isbusy()!=0);dataddr=0xff;conport&=~(1<11、=12、(1<13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
7、(1<8、=(1<9、C=_BV(URSEL)10、0x06;UBRRL=ubbrl;//setbaudratelo//UBRRH=ubbrh;//setbaudratehiUCSRB=0x90;}voidwritedata(unsignedcharcom,unsignedcharbusy_flag){if(busy_flag) while(isbusy()!=0);dataddr=0xff;conport&=~(1<11、=12、(1<13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
8、=(1<9、C=_BV(URSEL)10、0x06;UBRRL=ubbrl;//setbaudratelo//UBRRH=ubbrh;//setbaudratehiUCSRB=0x90;}voidwritedata(unsignedcharcom,unsignedcharbusy_flag){if(busy_flag) while(isbusy()!=0);dataddr=0xff;conport&=~(1<11、=12、(1<13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
9、C=_BV(URSEL)
10、0x06;UBRRL=ubbrl;//setbaudratelo//UBRRH=ubbrh;//setbaudratehiUCSRB=0x90;}voidwritedata(unsignedcharcom,unsignedcharbusy_flag){if(busy_flag) while(isbusy()!=0);dataddr=0xff;conport&=~(1<11、=12、(1<13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
11、=
12、(1<13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
13、=(1<14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
14、=(1<15、rt16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
15、rt
16、=(1<17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
17、writecom(0x01,1);//清除屏幕 writecom(0x06,1); writecom(0x0c,1);}; //写指定坐标,制定文字(x为横向y为纵向x={0,...13}y={0,1}voidwritelocatechar(unsignedcharx,unsignedchary,unsignedcharch){ writecom(128+x+y*0x40,1); writedata(ch,1);}//字符串长度计算函数p指向字符串的
此文档下载收益归作者所有