12864模块ST7565R并口画点画线测试程序

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

E:\工作项目\DJM12864G_ST7565R_8080_6800_Serial\DJM12864G_ST7565R_8080_6800_Serial.CPage11/******************************************************2**model:DJM12864G3**Controller:ST7565R4**VDD:3.3V5**Logic:6**seg1...seg1287**com32-|-------|-8**||9**com31-|-------|-10**notes:page--com32~com63,com0~com3111**col--sge1~seg12812********************************************************************13Ver:V1.014Finaldate:2016/0615********************************************************************/16#includereg52.h17#includeintrins.h18#includestring.h19#includeASCII_5X8_12864.h20#includebmp.h2122#defineUcharunsignedchar23#defineUintunsignedint2425#defineDispXpixel12826#defineDispYpixel642728sbitCS1=P3^5;29sbitRES=P3^4;30sbitRS=P3^3;3132#defineDATA_808033//#defineDATA_680034//#defineSerial3536#ifdefDATA_680037sbitRW=P3^1;38sbitE=P3^0;39#definedataportP140#endif4142#ifdefDATA_808043sbitWRR=P3^1;44sbitRDD=P3^0;45#definedataportP146#endif4748#ifdefSerial49sbitSCLK=P1^6;//d650sbitSDI=P1^7;//d751#endif5253UcharcodePageTable[]={0,1,2,3,4,5,6,7};5455//----------------------------------------------------------56voidDelay(Uinttimes)//延时57{58while(times)59{60times--;61}62}63//----------------------------------------------------------64voidCheckBusy()//判忙65{66CS1=0;67Delay(1);68RS=0;69WRR=1;70dataport=0xFF;71Delay(1);72RDD=0;73Delay(1);74while(dataport&0x80);75Delay(1);76RDD=1;77Delay(1);78CS1=1;E:\工作项目\DJM12864G_ST7565R_8080_6800_Serial\DJM12864G_ST7565R_8080_6800_Serial.CPage279}80//----------------------------------------------------------81voidWriteData(Uchardata1,bitdi)//写数据和写命令82{8384#ifdefSerial85Uchari,temp;86CS1=0;87RS=di;88for(i=0;i8;i++)89{90temp=data1;91SDI=temp&0x80;92SCLK=0;93SCLK=1;94data1=1;95}9697CS1=1;98#endif99100#ifdefDATA_8080101CheckBusy();102CS1=0;103RS=di;104RDD=1;105dataport=data1;106WRR=0;107Delay(1);108WRR=1;109Delay(1);110CS1=1;111#endif112113#ifdefDATA_6800114CheckBusy();115CS1=0;116RS=di;117RW=0;118dataport=data1;119E=1;120_nop_();121E=0;122_nop_();123RW=1;124125CS1=1;126#endif127128}129130UcharReadData()//读数据131{132UcharRdata;133#ifdefDATA_8080134CheckBusy();135CS1=0;136Delay(1);137WRR=1;138RS=1;139Delay(1);140RDD=0;141Delay(1);142Rdata=dataport;143RDD=1;144Delay(1);145CS1=1;146#endif147148#ifdefDATA_6800149CheckBusy();150CS1=0;151RS=1;152RW=1;153E=1;154Delay(1);155Rdata=dataport;156Delay(1);E:\工作项目\DJM12864G_ST7565R_8080_6800_Serial\DJM12864G_ST7565R_8080_6800_Serial.CPage3157E=0;158Delay(1);159CS1=1;160#endif161162returnRdata;163}164//----------------------------------------------------------165voidInit_lcd(void)//初始化166{167RES=1;168Delay(200);169RES=0;170Delay(200);171Delay(500);172Delay(200);173RES=1;174Delay(200);175176WriteData(0xe2,0);//commandreset177WriteData(0xC8,0);//COM63---COM0178WriteData(0xa0,0);//ADCsetS0--S131179WriteData(0xa2,0);//1/64duty,a2=1/9bias,a3=1/7bias180WriteData(0xa6,0);//Normaldisplay(orreversedisplay)181WriteData(0xa4,0);//Entiredisplaydisable182183WriteData(0x2c,0);184WriteData(0x2e,0);185WriteData(0x2f,0);//voltagefollowON,regulatorON,boosterON186Delay(100);187188WriteData(0x25,0);//V0voltageregulatorinternalresistorset189WriteData(0x81,0);//SetEV190WriteData(0x21,0);//EVelectronicvolumeset191192WriteData(0x60,0);//Startlineaddress193WriteData(0xaf,0);//displayon194}195//----------------------------------------------------------196voidM_Delay(UintNOs)//延时197{198while(NOs)199{200Delay(200);201NOs--;202}203}204//----------------------------------------------------------205voidClearALL()//清屏206{207Ucharx,y;208for(y=0;y9;y++)209{210WriteData(y|0xb0,0);211WriteData(0x10,0);212WriteData(0x00,0);213for(x=0;x132;x++)214{215WriteData(0,1);216}217}218}219//----------------------------------------------------------220voidDispline(Uchar_data1,Uchar_data2)//横竖条梅花点扫描221{222Ucharx,y;223224for(y=0;y8;y++)225{226WriteData(PageTable[y]|0xb0,0);227WriteData(0x10,0);228WriteData(0x01,0);229for(x=0;x128;x++)230{231(x%2==0)?WriteData(_data1,1):WriteData(_data2,1);232}233}234}E:\工作项目\DJM12864G_ST7565R_8080_6800_Serial\DJM12864G_ST7565R_8080_6800_Serial.CPage4235//----------------------------------------------------------236voidDispChar(Ucharcol,Ucharpage,Ucharcchar)//指定位置写5*8单个字符237{238Uintz,dat;239240dat=(cchar-0x20)*5;241WriteData((PageTable[page])|0xb0,0);242WriteData((col4)|0x10,0);243WriteData(col&0x0f,0);244245for(z=0;z5;z++)246{247WriteData(ASCII_5X8_12864[dat+z],1);248}249}250//----------------------------------------------------------251voidDispStr(Ucharcol,Ucharpage,Uchar*_char)//指定位置写5*8字符串252{253while(*_char!='\0')254{255if(col(DispXpixel-5))256{257col=1;page+=1;258}259if(page7)page=0;260261DispChar(col,page,*_char++);262col+=5;263}264}265//----------------------------------------------------------266voidDispHZ(Ucharcol,Ucharpage,Uchar*charr)//指定位置写16*16汉字267{268Uintz,cc;269Uchary;270271for(y=0;y28;y++)272{273for(cc=0;cc2;cc++)274{275WriteData((PageTable[page])|0xb0,0);276WriteData((col4)|0x10,0);277WriteData(col&0x0f,0);278for(z=0;z16;z++)279{280WriteData(*charr

1 / 7
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功