//实验目的:熟悉12864LCD的使用 //12864LCD带中文字库 //编程让12864LCD显示公司LOGO和公司名字 //硬件设置:
//源程序来自:PIC单片机学习网 http://www.pic16.com //关断所有拨码开关。 #include <p30f6014.h> //dsPIC30F6014标准头文件 _FOSC(CSW_FSCM_OFF & XT_PLL4); //4倍频晶振,Failsafe 时钟关闭 _FWDT(WDT_OFF); //关闭看门狗定时器 _FBORPOR(PBOR_OFF & MCLR_EN); //掉电复位禁止,MCLR复位使能。 _FGS(CODE_PROT_OFF); //代码保护禁止 #define di LATBbits.LATB4 //命令/数据选择 #define rw LATBbits.LATB5 //读/写选择 #define e LATBbits.LATB6 //使能 #define psb LATBbits.LATB2 //8位/4位并口选择 #define rst LATBbits.LATB7 //复位 unsigned int __attribute__((address(0x900))) temp; unsigned int __attribute__((address(0x902))) temp1; const unsigned char TAB1[ ]={ //定义显示图片的数据表 0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0X00,0X81,0X00,0X10,0X40,0X00,0X02,0X41, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0X00,0X81,0X00,0X10,0X40,0X00,0X02,0X41, 0XFF,0XFF,0XC0,0X00,0X00,0X7F,0XFF,0XFF, 0X07,0XE2,0X00,0XFE,0XC0,0X00,0X06,0X01, 0XFF,0XFF,0X00,0X00,0X00,0X1F,0XFF,0XFF, 0X01,0X87,0XE0,0X00,0X80,0X03,0XFF,0XF1, 0XFF,0XFC,0X00,0X00,0X00,0X07,0XFF,0XFF, 0X01,0X04,0X00,0X44,0XFC,0X02,0X04,0X01, 0XFF,0XF0,0X00,0X00,0X00,0X07,0XFF,0XFF, 0X01,0X08,0X00,0X48,0X04,0X02,0X04,0X41, 0XFF,0XF0,0X00,0X00,0X00,0X03,0XFF,0XFF, 0X0F,0XD8,0X00,0X08,0X04,0X03,0XF6,0X81, 0XFF,0XF0,0X00,0X00,0X00,0X01,0XFF,0XFF, 0X08,0X40,0X01,0XFE,0XFC,0X06,0X27,0X01, 0XFF,0XF0,0X00,0X00,0X00,0X01,0XFF,0XFF, 0X0F,0XCF,0X80,0X01,0X00,0X04,0X23,0X01, 0XFF,0XF0,0X3F,0XF0,0X3F,0XC1,0XFF,0XFF, 0X08,0XC1,0X00,0X01,0X00,0X04,0XE7,0X21, 0XFF,0XF0,0X7F,0XE0,0X7F,0XC1,0XFF,0XFF, 0X10,0X82,0X01,0XF9,0XF8,0X08,0X99,0XA1, 0XFF,0XF0,0X7F,0XE0,0X7F,0XC1,0XFF,0XFF, 0X1F,0X86,0X01,0X09,0X00,0X08,0X10,0XE1, 0XFF,0XF0,0XFF,0XC0,0XFF,0XC1,0XFF,0XFF, 0X06,0X04,0X01,0X09,0XF0,0X00,0X00,0X01, 0XFF,0XF0,0XFF,0XC1,0XFF,0XC1,0XFF,0XFF, 0X04,0X08,0X01,0XFA,0X00,0X07,0XFF,0X01, 0XFF,0XF0,0XFF,0X83,0XFF,0XC1,0XFF,0XFF, 0X7F,0XD0,0X03,0X12,0X00,0X06,0X89,0X01, 0XFF,0XF0,0XFF,0X03,0XFF,0XC1,0XFF,0XFF, 0X04,0X10,0X83,0X13,0XF0,0X08,0X91,0X01, 0XFF,0XF0,0XFE,0X07,0XFF,0XC1,0XFF,0XFF, 0X04,0X10,0X83,0XF2,0X00,0X08,0X91,0X01, 0XFF,0XF0,0XFC,0X0F,0XFF,0XC1,0XFF,0XFF, 0X04,0X3F,0X02,0X12,0X08,0X1B,0X93,0X01, 0XFF,0XF0,0XFC,0X0F,0XFF,0XC1,0X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,0XFF,0XC0,0X00,0X3F,0XFF,0XFF,0XFF, 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01, 0XFF,0XFF,0X80,0X00,0X1F,0XFF,0XFF,0XCF, 0X3E,0X83,0XE7,0X3E,0X78,0X21,0X14,0XE1, 0XFF,0XFE,0X00,0X00,0X07,0XFF,0XFC,0X3F, 0X20,0X82,0X09,0X88,0X44,0X51,0X15,0X31, 0XFF,0XFC,0X7C,0X00,0X00,0XFF,0XC0,0X7F, 0X20,0X82,0X08,0X88,0X44,0X51,0X95,0X11, 0XFF,0XFF,0XFF,0XF0,0X00,0X00,0X01,0XFF, 0X20,0X82,0X08,0X08,0X44,0X89,0X95,0X01, 0XFF,0XFF,0XFF,0XFE,0X00,0X00,0X03,0XFF, 0X20,0X82,0X08,0X08,0X44,0X89,0X55,0X01, 0XFF,0XFF,0XFF,0XFF,0X80,0X00,0X07,0XFF, 0X3E,0X83,0XE8,0X08,0X44,0X89,0X55,0X01, 0XFF,0XFF,0XFF,0XFF,0XE0,0X00,0X1F,0XFF, 0X20,0X82,0X08,0X08,0X78,0X89,0X55,0X01, 0XFF,0XFF,0XFF,0XFF,0XFC,0X00,0XFF,0XFF, 0X20,0X82,0X08,0X08,0X48,0X89,0X55,0X01, 0XFF,0XFF,0XFF,0XFF,0XFE,0X03,0XFF,0XFF, 0X20,0X82,0X08,0X08,0X48,0X89,0X35,0X01, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0X20,0X82,0X08,0X88,0X44,0X51,0X35,0X11, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0X20,0X82,0X09,0X88,0X44,0X51,0X15,0X31, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0X3E,0XF3,0XE7,0X08,0X44,0X21,0X14,0XE1, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01, 0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, 0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE, }; unsigned int lcd_x; //X地址 unsigned int lcd_y; //Y地址 // bit busy; //忙标志位 void init(); //系统初始函数 void lcd_init(); //LCD初始函数 void clear_p(); //清屏函数 void han_wr2a(); //写函数 void wr_zb(); //写准备函数 void qushu(); //查表函数 void send_d(unsigned char x); //写一字节数据函数 void send_i(unsigned char x); //写一字节命令函数 void chk_busy(); //查LCD忙函数 void delay(); //------------------------------------------- int main(void) { init(); //系统初始化 lcd_init(); //LCD初始化 clear_p(); //清除显示 qushu(); //写数据到LCD显示 while(1); } //------------------------------------------- void init() { TRISB=0X0000; //设置B口为输出 TRISD=0X0000; //设置D口为输出 } //------------------------------------------- void lcd_init() { rst=0; //复位LCD delay(); rst=1; //LCD正常工作 delay(); psb=1; //8位并行通信 send_i(0x30); //基本操作指令 send_i(0x01); //关显示 send_i(0x06); //指定在写入或读取时,光标的移动方向 send_i(0x0c); //开显示,关光标,不闪烁 } //------------------------------------------- void wr_zb() { send_i(0x34); //扩展操作指令 send_i(lcd_y); //设置Y地址 send_i(lcd_x); //设置X地址 send_i(0x30); //基本操作指令 } //------------------------------------------- void clear_p() { send_i(0x1); //清除显示 send_i(0x34); //扩展操作指令 send_i(0x30); //基本操作指令 } //------------------------------------------ void qushu() { unsigned char i,j,k; //定义临时变量 temp=0; //查表偏移地址 lcd_x=0x0080; //上半屏X地址80H for(i=0;i<2;i++) //共两屏 { lcd_y=0x0080; //每一行的Y地址80H(即顶格显示) for(j=0;j<32;j++) //每半屏共20H行 { wr_zb(); //写准备(设置X地址和Y地址) for(k=0;k<16;k++) //每一行16字节(因为顶格写) { temp1=TAB1[temp]; //查表获取显示数字 send_d(temp1); //送LCD显示 temp++; //查表偏移地址+1 } lcd_y++; //送下一行数据 send_i(0x0036); //扩展指令操作:图形显示开 send_i(0x0030); //基本指令操作 } lcd_x=0X0088; //下半屏X地址 } } //------------------------------------------- void send_d(unsigned char x) { chk_busy(); //判断LCD是否忙 di=1; //总线上是数据 delay(); rw=0; //写操作 delay(); PORTD=x; //数据送总线 e=1; //使能 delay(); e=0; delay(); } //-------------------------------------------- void send_i(unsigned char x) { chk_busy(); //判断忙信号 di=0; //总线上是命令 delay(); rw=0; //写操作 delay(); PORTD=x; //数据送总线 e=1; //使能 delay(); e=0; delay(); } //------------------------------------------- void chk_busy() { // busy=1; //先置忙信号 TRISD=0Xffff; //更改总线方向为输入 di=0; //总线上为命令 delay(); rw=1; //读操作 delay(); while(PORTDbits.RD7) { delay(); delay(); e=1; delay(); delay(); e=0; } e=0; TRISD=0X0000; //总线还原为输出 } //------------------------------------------- void delay() { int m; for(m=0;m<10;m++) {;} }
共5条
1/1 1 跳转至页
发个12864LCD程序学习一下
关键词: 发个 12864LCD 程序 学习 一下 显示 u
QLdsPIC3 PIC单片机综合开发实验系统 http://www.pic16.com/wzcapi/dspic3.htm
共5条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
vscode+cmake搭建雅特力AT32L021开发环境被打赏30分 | |
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 |