此程序用于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]);
}
}
}
上一篇:基于ZigBee的无线气体监测系统的设计方案
下一篇:PIC18F2680的CAN总线设计
推荐阅读最新更新时间:2024-03-16 15:08
设计资源 培训 开发板 精华推荐
- 半导体行业在线会员系统问卷调查 快来参与抽取50元京东卡!
- 让是德科技带我们一起 了解汽车电子车载系统解决方案 看视频答题赢好礼!
- 【泰克注册观看有礼】 PCI-SIG 前主席解析:PCI Express5.0测试方案和测量挑战
- 了解PI InnoSwitch-CE,答题赢好礼
- 意法半导体工业峰会2023即将开启!报名、参会均有礼!
- 独乐乐不如众乐乐——TI培训“荐课”功能上线公测,邀你提议,参与抢楼!
- 限时秒杀,100本专业书籍——TI 中国大学计划20周年
- 听技术大咖侃谈Type-C 测量那些事儿—— 即刻获取能量,轻松闯关赢礼品!
- 今天上午10:0有奖直播|完美替代传统汽车钥匙?探索英飞凌数字钥匙解决方案
- 电工也疯狂!玩游戏,晒得分,赢4G U盘!