欢迎来到天天文库
浏览记录
ID:22637216
大小:172.08 KB
页数:16页
时间:2018-10-30
《实验mega1612864串行驱动》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、//ICC-AVRapplicationbuilder:2015-7-310:21:56//Target:Ml28//Crystal:l.OOOOMhz/tlf*1?tlf*Xftl?tlf/^Tw^T、^T、^T、^T、^T、目的:建立液晶4x8c使用示例目标系统:蕋于AVR单片机应用软件:ICCAVR版本更新记录:实验内容:通过串行控制使液品OCM4X8C显示字符阁像硬件连接:PD.O->CS/RSPD.l->SID/R/WPD.2->SCLK/EPD.3->PSBPD.4->RST注意事项:详见说明书#include2、h〉include〈D:AVR.H〉#defineuintunsignedint#defineucharunsignedchar#definexl0x80#definex20x88#definey0x80#definecomm0#definedal1#defineCS_ONsetb(PORTD,0)defineCS_OFFclr(PORTD,0)#defineSTD^ONsetb(PORTD,1)#defineSTD.OFFclr(PORTDJ)#defineSCLK_ONsetb(P0RTD,2)#defineSCLK_OFFclr(3、PORTD,2)//H=并口;L=串口;#definePSB_ONsetb(PORTD,3)#definePSB_OFFclr(PORTD,3)//ResetSignal低电平有效#defineRST_ONsetb(P0RTD,4)#defineRST_OFFclr(PORTD,4)#defineTURE1externcharbufferl0[7];voidwr_lcd(uchardat_comm,ucharcontent);voiddelay(uintus);#pragmadata:datauchartable_l[]={n锄禾日当午”4、"汗滴禾下土”谁知盘中餐"粒粒皆辛苦uchartable_0[l={"鹅鹅鹅"”曲项向天歌n白毛浮绿水”红掌拨青波};ucharconsttable_2[12]={n0123456789:H};ucharYear_[]={"年"};ucharWeek_[]={"星"};ucharWeekl_[]={^期^};ucharMonth_[l={n月n};ucharDay_[]={"0"};ucharHour_[]={n吋"};ucharMinute」]={”分’•};ucharSecond_[j={"秒;ucharRegulate_[]={"调5、”};///调节ucharding_[]={"定"};ucharshi_[]={"时"};ucharkai_U={"开ucharguan_[]={"关"};ucharover_[]={Hucharone_n={M—uchartwo_[]=「.二"};ucharthree_[]={"三"};ucharfore_[]={"四n};ucharfive_[l={n£"};ucharsix_[]={"六"};ucharseven_[]={"H"};ucharwen_[]={"温uchardu_U={"度••};uchardian_[]={.?};u6、charshes_[]={H°Cuucharmaohao_[]={*/voiddelay(uintus)//delaytime{while(us-);}voiddelay1(uintms){uintij;for(i=0;i7、lay(100);wr_lcd(comm,0x06);/*光标的移动方向*/wr_lcd(comm,0x0c);/*开显示,关辦标*/}/*显示汉字或字符*/voidchn_disp(uchar*chn){ucharij;wr_lcd(comm,0x30);wr_lcd(comm,0x80);fora=0;j<4;j++){for(i=0;i<16;i++)wr_lcd(dat,chn[j*16+i]);}}/*上半屏显示汉字或字符*//*voidchn_disp1(uchar*chn){uchari,j;wr—led(comm,0x308、);wr_lcd(comm,0x80);j=0;for(i=0;i<16;i++)wrjcd(dat,chn9、j*16+ij);wr_lcd(comm,0x90);j=l;for(i=0;i<
2、h〉include〈D:AVR.H〉#defineuintunsignedint#defineucharunsignedchar#definexl0x80#definex20x88#definey0x80#definecomm0#definedal1#defineCS_ONsetb(PORTD,0)defineCS_OFFclr(PORTD,0)#defineSTD^ONsetb(PORTD,1)#defineSTD.OFFclr(PORTDJ)#defineSCLK_ONsetb(P0RTD,2)#defineSCLK_OFFclr(
3、PORTD,2)//H=并口;L=串口;#definePSB_ONsetb(PORTD,3)#definePSB_OFFclr(PORTD,3)//ResetSignal低电平有效#defineRST_ONsetb(P0RTD,4)#defineRST_OFFclr(PORTD,4)#defineTURE1externcharbufferl0[7];voidwr_lcd(uchardat_comm,ucharcontent);voiddelay(uintus);#pragmadata:datauchartable_l[]={n锄禾日当午”
4、"汗滴禾下土”谁知盘中餐"粒粒皆辛苦uchartable_0[l={"鹅鹅鹅"”曲项向天歌n白毛浮绿水”红掌拨青波};ucharconsttable_2[12]={n0123456789:H};ucharYear_[]={"年"};ucharWeek_[]={"星"};ucharWeekl_[]={^期^};ucharMonth_[l={n月n};ucharDay_[]={"0"};ucharHour_[]={n吋"};ucharMinute」]={”分’•};ucharSecond_[j={"秒;ucharRegulate_[]={"调
5、”};///调节ucharding_[]={"定"};ucharshi_[]={"时"};ucharkai_U={"开ucharguan_[]={"关"};ucharover_[]={Hucharone_n={M—uchartwo_[]=「.二"};ucharthree_[]={"三"};ucharfore_[]={"四n};ucharfive_[l={n£"};ucharsix_[]={"六"};ucharseven_[]={"H"};ucharwen_[]={"温uchardu_U={"度••};uchardian_[]={.?};u
6、charshes_[]={H°Cuucharmaohao_[]={*/voiddelay(uintus)//delaytime{while(us-);}voiddelay1(uintms){uintij;for(i=0;i7、lay(100);wr_lcd(comm,0x06);/*光标的移动方向*/wr_lcd(comm,0x0c);/*开显示,关辦标*/}/*显示汉字或字符*/voidchn_disp(uchar*chn){ucharij;wr_lcd(comm,0x30);wr_lcd(comm,0x80);fora=0;j<4;j++){for(i=0;i<16;i++)wr_lcd(dat,chn[j*16+i]);}}/*上半屏显示汉字或字符*//*voidchn_disp1(uchar*chn){uchari,j;wr—led(comm,0x308、);wr_lcd(comm,0x80);j=0;for(i=0;i<16;i++)wrjcd(dat,chn9、j*16+ij);wr_lcd(comm,0x90);j=l;for(i=0;i<
7、lay(100);wr_lcd(comm,0x06);/*光标的移动方向*/wr_lcd(comm,0x0c);/*开显示,关辦标*/}/*显示汉字或字符*/voidchn_disp(uchar*chn){ucharij;wr_lcd(comm,0x30);wr_lcd(comm,0x80);fora=0;j<4;j++){for(i=0;i<16;i++)wr_lcd(dat,chn[j*16+i]);}}/*上半屏显示汉字或字符*//*voidchn_disp1(uchar*chn){uchari,j;wr—led(comm,0x30
8、);wr_lcd(comm,0x80);j=0;for(i=0;i<16;i++)wrjcd(dat,chn
9、j*16+ij);wr_lcd(comm,0x90);j=l;for(i=0;i<
此文档下载收益归作者所有