您的位置 首页 设计

PIC16F74的12864点阵液晶驱动(不带字库)

驱动程序如下:此程序用于12864不带字库点阵液晶屏使用*/#includepic.h>#defineDATAPORTB//RB端口为8位数据端口#defineBusyRB…

驱动程序如下:

此程序用于12864不带字库点阵液晶屏运用
*/
#include

#define DATA PORTB //RB端口为8位数据端口
#define Busy RB7 //RB7为忙标志位,数据的高位
#define RS RC1 //操控引脚阐明
#define RW RC2
#define E RC3
#define CS1 RD2
#define CS2 RD3
//—————数据界说—————-
//12867为纵向8点下高位
//每一页的摆放是纵向8位下高位,从左到右依次为64列
//下面是16*16的点阵字符代码
unsigned char const table[]={0x90,0x8c,0x84,0x84,0x84,0x84,0xf5,0x86,
0x84,0x84,0x84,0x84,0x84,0xd4,0x8c,0x00,
0x00,0x00,0x80,0x84,0x46,0x49,0x28,0x10,
0x10,0x28,0x47,0xc0,0x00,0x00,0x00,0x00}; //汉字安的代码
unsigned char const table1[]={0x08,0x08,0x88,0x88,0x88,0x88,0x88,0xff,
0x88,0x88,0x88,0xc8,0x88,0x0c,0x08,0x00,
0x00,0x00,0x00,0xfc,0x44,0x44,0x44,0x44,
0x44,0x44,0x44,0xff,0x04,0x00,0x00,0x00}; //吉字的点阵码
unsigned char const table2[]={0x10,0x10,0x10,0xd0,0xff,0x90,0x10,0x00,
0x10,0xd0,0xff,0x90,0x10,0x18,0x10,0x00,
0x08,0x04,0x03,0x00,0xff,0x00,0x09,0x04,
0x03,0x00,0xff,0x00,0x03,0x06,0x02,0x00}; //林字的点阵码
unsigned char const table3[]={0x00,0x00,0x00,0xfe,0x82,0x82,0x82,0x82,
0x82,0x82,0x82,0xff,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x7f,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x7f,0x00,0x00,0x00,0x00}; //日字的点阵码
unsigned char const table4[]={0x40,0x44,0x54,0x65,0xc6,0x64,0xd6,0x44,
0x40,0xfc,0x00,0x00,0xc3,0x62,0x40,0x00,
0x20,0x11,0x49,0x81,0x7f,0x01,0x05,0x29,
0x18,0x07,0x00,0x00,0xff,0x00,0x00,0x00}; //新字的点阵码
unsigned char const table5[]={0x08,0x08,0x88,0x88,0x88,0x88,0x88,0xff,0x88,0x88,0x88,0xc8,0x88,0x0c,0x08,0x00,
0x10,0x10,0x10,0xd0,0xff,0x90,0x10,0x00,0x10,0xd0,0xff,0x90,0x10,0x18,0x10,0x00,
0x00,0x00,0x00,0xfe,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xff,0x02,0x00,0x00,0x00,
0x40,0x44,0x54,0x65,0xc6,0x64,0xd6,0x44,0x40,0xfc,0x44,0x42,0xc3,0x62,0x40,0x00,
0x00,0x00,0x00,0xfc,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0xff,0x04,0x00,0x00,0x00,
0x08,0x04,0x03,0x00,0xff,0x00,0x09,0x04,0x03,0x00,0xff,0x00,0x03,0x06,0x02,0x00,
0x00,0x00,0x00,0x7f,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7f,0x00,0x00,0x00,0x00,
0x20,0x11,0x49,0x81,0x7f,0x01,0x05,0x29,0x18,0x07,0x00,0x00,0xff,0x00,0x00,0x00}; //吉林日新

//—————函数界说—————-
void picint(void);
void Leftwcom(unsigned char com); //左半屏写指令代码子程序
void Leftwdata(unsigned char ldata); //左半屏写显现数据子程序
void Rightwcom(unsigned char rcom); //右半屏写指令代码子程序
void Rightwdata(unsigned char rdata); //右半屏写显现数据子程序
void clear(void); //清屏函数
//***************************************
//初始化函数
//***************************************
void picint()
{
INTCON=0;
ADCON1=0x07; //AD口为通用IO口
TRISB=0; //RB端口为输出端口
PSPMODE=0; //装备D口为通用IO口

TRISC1=0; //输出引脚,操控引脚
TRISC2=0;
TRISC3=0;
TRISD3=0;
TRISD2=0;
}
//***************************************
//延时函数
//***************************************
void delay(unsigned int asd)
{
unsigned int i;
for(i=0;i {}
}
//***************************************
//左半屏写指令代码子函数
//***************************************
void Leftwcom(unsigned char com)
{
PORTB=0xff;
TRISB=0xff; //设置为输入引脚
E=1;
CS1=1;
CS2=1;
RS=0;
RW=1;
while(1)
{
E=1;
if(RB7==0) break;
E=0;
}
RW=0;
TRISB=0;
PORTB=com;
E=1; //送指令
E=0;
}
//***************************************
//左半屏写显现数据子函数
//***************************************
void Leftwdata(unsigned char ldata)
{
PORTB=0xff;
TRISB=0xff; //设置为输入
CS1=1;
CS2=1;
RS=0;
RW=1;
while(1)
{
E=1;
if(RB7==0) break;
E=0;
}
RS=1;
RW=0;
TRISB=0;
PORTB=ldata;
E=1;
E=0;
}
//***************************************
//右半屏写指令代码
//***************************************
void Rightwcom(unsigned char rcom)
{
PORTB=0xff;
TRISB=0xff; //设置为输入引脚
E=1;
CS1=1;
CS2=1;
RS=0;
RW=1;
while(1)
{
E=1;
if(RB7==0) break;
E=0;
}
RW=0;
TRISB=0;
PORTB=rcom;
E=1; //送指令
E=0;
}
//***************************************
//右半屏写数据代码
//***************************************
void Rightwdata(unsigned char rdata)
{
PORTB=0xff;
TRISB=0xff; //设置为输入
CS1=1;
CS2=1;
RS=0;
RW=1;
while(1)
{
E=1;
if(RB7==0) break;
E=0;
}
RS=1;
RW=0;
TRISB=0;
PORTB=rdata;
E=1;
E=0;
}
//***************************************
//清屏函数
//***************************************
void clear()
{
unsigned char i ,y;
for(i=0;i<3;i++)
{
Leftwcom(i|0xb8);
Rightwcom(i|0xb8);
for(y=0;y<64;y++)
{
Leftwdata(0x00);
Rightwdata(0x00);
}
}
}
//***************************************
//主函数
//***************************************
void main()
{
unsigned char i=0; //查表计数器
unsigned char z; //循环计数器
unsigned char y=0;
unsigned char e=0x40;
picint();
clear();
while(1)
{
Leftwcom(0xc0); //写指令,设置显现其实行为榜首行
Leftwcom(0x3f); //开显现设置
Leftwcom(0xb8); //设置榜首页
Leftwcom(0x40); //设置显现为榜首列
for(i=0;i<64;i++)
{
Leftwdata(table5[i]);
}
Leftwcom(0xb9); //设置榜首页
Leftwcom(0x40); //设置显现为榜首列
for(i=64;i<128;i++)
{
Leftwdata(table5[i]);
}
Rightwcom(0xc0); //写指令,设置显现其实行为榜首行
Rightwcom(0x3f); //开显现设置
Rightwcom(0xb8); //设置榜首页
Rightwcom(0x40); //设置显现为榜首列
for(i=0;i<64;i++)
{
Rightwdata(table5[i]);
}
Rightwcom(0xb9); //设置榜首页
Rightwcom(0x40); //设置显现为榜首列
for(i=64;i<128;i++)
{
Rightwdata(table5[i]);
}
}
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/ziliao/sheji/266982.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部