【附:这次实验用的程序】
/********************************************************************
* *
* LCM12864带字库演示程序 - 12864显示图片和文字 *
* *
* 控制芯片ST7920,并口模式。 *
* *
* 东莞市智杰电子科技有限公司 *
* 展柜地址:东莞市长安明和电子广场B区B-B1019 *
* 电话:0769-89268669 *
* *
********************************************************************/ #include <reg52.h>
#include
<intrins.h> /************* 12864LCD引脚定义 *************/ #define
LCD_data P0 //数据口 sbit LCD_RS = P2 ^ 0; //寄存器选择输入
sbit LCD_RW = P2 ^ 1; //液晶读/写控制
sbit LCD_EN = P2 ^ 2; //液晶使能控制
sbit LCD_PSB = P2 ^ 3; //串/并方式控制
sbit LCD_RST = P2 ^ 5; //液晶复位端口 /*********************************************************/ unsigned char code DIS1[] =
{
"东莞智杰电子科技"
};
unsigned char code DIS2[] =
{
"ZhiJieElectronic"
};
unsigned char code DIS3[] =
{
"单片机 开发板"
};
unsigned char code DIS4[] =
{
"编程器 液晶模块"
};
char code reserve[3]_at_ 0x3b; //保留0x3b开始的3个字节
/*********************************************************/ unsigned
char code Photo1[] =
{
/*-- 智杰电子图片 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x40,0x18,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x7F,0x1C,0x00,0x00,0x02,
0x40,0x10,0x04,0x08,0x00,0x02,0x00,0x00,0x00,0x00,0x1E,0x7F,0xFC,0x00,0x00,0x02,
0x40,0x3F,0xE7,0xFC,0x00,0x02,0x00,0x00,0x00,0x07,0x9F,0x80,0x06,0x00,0x00,0x02,
0x40,0x22,0x04,0x18,0x00,0x02,0x01,0x80,0x00,0x7F,0xE0,0x00,0x02,0x00,0x60,0x02,
0x40,0x46,0x04,0x18,0x1F,0xFF,0xFF,0xC0,0x0F,0xF8,0x00,0x00,0x01,0x00,0xF0,0x02,
0x40,0x86,0x24,0x18,0x00,0x0E,0x80,0x01,0xFF,0x80,0x00,0x00,0x01,0x03,0x9C,0x02,
0x41,0xFF,0xF4,0x18,0x00,0x1A,0x80,0x01,0xF0,0x00,0x00,0x00,0x01,0x0E,0x06,0x02,
0x40,0x04,0x04,0x18,0x00,0x1A,0x40,0x06,0x00,0x00,0x00,0x00,0x01,0x18,0x33,0x02,
0x40,0x0F,0x04,0x18,0x00,0x32,0x60,0x02,0x00,0x00,0x00,0x00,0x01,0x30,0x31,0xC2,
0x40,0x08,0xC7,0xF8,0x00,0x62,0x30,0x01,0xC0,0x00,0x00,0x00,0x01,0x60,0x03,0xC2,
0x40,0x18,0x64,0x18,0x00,0xC2,0x1C,0x00,0xC0,0x00,0x00,0x00,0x00,0xC0,0x0E,0x02,
回复
5楼
2012-01-28 11:43
删除 |
巨大八爪鱼
学业有成8
0x40,0x30,0x24,0x10,0x01,0x82,0x0F,0x00,0x38,0x00,0x00,0x00,0x01,0x80,0x0C,0x02,
0x40,0x48,0x00,0x40,0x02,0x02,0x03,0xC0,0x1E,0x00,0x00,0x00,0x03,0x00,0x18,0x02,
0x41,0x8F,0xFF,0xE0,0x0C,0x02,0x00,0x80,0x06,0x00,0x00,0x00,0x02,0x00,0x30,0x02,
0x40,0x0C,0x00,0xC0,0x10,0x02,0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x20,0x02,
0x40,0x0C,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x5C,0x00,0x00,0x00,0x00,0x60,0x02,
0x40,0x0C,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x1B,0x80,0x00,0x00,0x00,0x60,0x02,
0x40,0x0F,0xFF,0xC0,0x02,0x20,0x84,0x00,0x00,0x03,0xF0,0x00,0x00,0x00,0x60,0x02,
0x40,0x0C,0x00,0xC0,0x02,0x20,0xC2,0x03,0x00,0x00,0x7E,0x00,0x00,0x00,0x40,0x02,
0x40,0x0C,0x00,0xC0,0x02,0x10,0x43,0x87,0xC0,0x00,0x0F,0x80,0x00,0x00,0x5E,0x02,
0x40,0x0C,0x00,0xC0,0x06,0x18,0x61,0x86,0xFC,0x00,0x01,0xE0,0x00,0x00,0xDF,0xC2,
0x40,0x0F,0xFF,0xC0,0x0C,0x18,0x61,0x86,0x1F,0xD0,0x00,0x60,0x00,0x00,0x80,0xE2,
0x40,0x0C,0x00,0xC0,0x0C,0x18,0x40,0x86,0x01,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x3A,
0x40,0x08,0x00,0x80,0x00,0x00,0x00,0x06,0x00,0x0F,0xFE,0x00,0x00,0x00,0x00,0x3A,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1A,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1A,
0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0A,
0x40,0x00,0x30,0x00,0x00,0x00,0x01,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0A,
0x40,0x00,0x30,0x00,0x03,0xFF,0xFF,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0A,
0x40,0x00,0x30,0x00,0x00,0x00,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0A,
0x40,0x00,0x30,0x00,0x00,0x00,0x0C,0x01,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x0A,
0x40,0x30,0x30,0x30,0x00,0x00,0x10,0x01,0x80,0x00,0x3F,0xFF,0xFC,0x00,0x00,0x3A,
0x40,0x3F,0xFF,0xF0,0x00,0x00,0x60,0x01,0x80,0x00,0x71,0xFF,0xF0,0x00,0x00,0x32,
0x40,0x30,0x30,0x30,0x00,0x01,0x80,0x00,0x80,0x01,0xC0,0x00,0x0C,0x00,0x00,0x22,
0x40,0x30,0x30,0x30,0x00,0x01,0xC0,0x00,0xC0,0x03,0x80,0x00,0x0C,0x00,0x00,0x62,
0x40,0x30,0x30,0x30,0x00,0x01,0x80,0x00,0xC0,0x0E,0x00,0x00,0x18,0x00,0x00,0xC2,
0x40,0x30,0x30,0x30,0x00,0x01,0x80,0xE0,0x60,0x3C,0x00,0x00,0x18,0x00,0x01,0x82,
0x40,0x3F,0xFF,0xF0,0x0F,0xFF,0xFF,0xF0,0x60,0x70,0x00,0x00,0x30,0x00,0x03,0x02,
0x40,0x30,0x30,0x30,0x00,0x01,0x80,0x00,0x31,0xC0,0x00,0x00,0x70,0x00,0x06,0x02,
0x40,0x30,0x30,0x30,0x00,0x01,0x80,0x00,0x13,0x80,0x00,0x00,0x60,0x00,0x1C,0x02,
0x40,0x30,0x30,0x30,0x00,0x01,0x80,0x00,0x1E,0x00,0x00,0x00,0xC0,0x00,0x70,0x02,
0x40,0x30,0x30,0x30,0x00,0x01,0x80,0x00,0x0C,0x00,0x00,0x00,0x80,0x00,0xC0,0x02,
0x40,0x3F,0xFF,0xF0,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x01,0x80,0x07,0x80,0x02,
0x40,0x30,0x30,0x20,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x03,0x00,0x1E,0x00,0x02,
0x40,0x20,0x30,0x04,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x03,0x00,0xF8,0x00,0x02,
0x40,0x00,0x30,0x04,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x0C,0x03,0xC0,0x00,0x02,
0x40,0x00,0x30,0x04,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x18,0x0F,0x00,0x00,0x02,
0x40,0x00,0x30,0x06,0x00,0x21,0x80,0x00,0x00,0x00,0x00,0x30,0x7C,0x00,0x00,0x02,
巨大八爪鱼
学业有成8
0x40,0x00,0x30,0x06,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x61,0xE0,0x00,0x00,0x02,
0x40,0x00,0x1F,0xFE,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0xC7,0x80,0x00,0x00,0x02,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x9C,0x00,0x00,0x00,0x02,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0x02,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x02,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
}; /********************************************************** us延时子函数
(4.34us) **********************************************************/
void delayNOP()
{
_nop_();
_nop_();
_nop_();
_nop_();
}
/********************************************************** ms延时子函数
***********************************************************/
void delayms(unsigned int ms)
{
unsigned char y;
while (ms--)
{
for (y = 0; y < 114; y++)
;
}
} /********************************************************** 检查LCD忙状态
lcd_busy为1时,忙,等待。
lcd-busy为0时,闲,可写指令与数据。 **********************************************************/
bit lcd_busy()
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delayNOP();
result = (bit)(P0 &0x80);
LCD_EN = 0;
return (result);
} /********************************************************** 写指令数据到LCD
RS=L,RW=L,E=高脉冲,D0-D7=指令码。 **********************************************************/
void lcd_wcmd(unsigned char cmd)
{
while (lcd_busy())
;
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 1;
P0 = cmd;
delayNOP();
LCD_EN = 0;
} /********************************************************** 写显示数据到LCD
RS=H,RW=L,E=高脉冲,D0-D7=数据。 **********************************************************/
void lcd_wdat(unsigned char dat)
{
while (lcd_busy())
;
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 1;
P0 = dat;
delayNOP();
LCD_EN = 0;
}
/********************************************************** LCD初始化设定
**********************************************************/
void lcd_init()
{
LCD_PSB = 1; //并口方式 LCD_RST = 0; //液晶复位
delayms(5);
LCD_RST = 1;
delayms(5); lcd_wcmd(0x34); //扩充指令操作
delayms(5);
lcd_wcmd(0x30); //基本指令操作
delayms(5);
lcd_wcmd(0x0C); //显示开,关光标
delayms(5);
lcd_wcmd(0x06); //光标的移动方向
delayms(5);
lcd_wcmd(0x01); //清除LCD的显示内容
delayms(5);
}
/********************************************************** 设定显示位置子函数
**********************************************************/
巨大八爪鱼
学业有成8
void lcd_pos(unsigned char X, unsigned char Y)
{
unsigned char pos; if (X == 1)
{
X = 0x80;
}
else if (X == 2)
{
X = 0x90;
}
else if (X == 3)
{
X = 0x88;
}
else if (X == 4)
{
X = 0x98;
}
pos = X + Y; //确定显示地址 lcd_wcmd(pos); //写显示地址
} /********************************************************** 闪烁子函数 **********************************************************/
void lcdflag()
{
lcd_wcmd(0x08); //关闭显示
delayms(1000);
lcd_wcmd(0x0c); //开启显示
delayms(1000);
lcd_wcmd(0x08);
delayms(1000);
lcd_wcmd(0x0c);
delayms(1000);
lcd_wcmd(0x08);
delayms(1000);
lcd_wcmd(0x0c);
delayms(1000);
lcd_wcmd(0x01); //清屏
delayms(5);
}
/********************************************************** 图形显示子函数
**********************************************************/
void photodisplay(unsigned char *bmp)
{
unsigned char i, j; lcd_wcmd(0x34); //写数据时,关闭图形显示 for (i = 0; i < 32; i++)
//32行(上半屏)
{
lcd_wcmd(0x80 + i); //先写入Y坐标值
lcd_wcmd(0x80); //写入X坐标值
for (j = 0; j < 16; j++)
//16*8列
lcd_wdat(*bmp++);
delayms(1);
} for (i = 0; i < 32; i++)
//32行(下半屏)
{
lcd_wcmd(0x80 + i); //先写入Y坐标值
lcd_wcmd(0x88); //写入X坐标值
for (j = 0; j < 16; j++)
//16*8列
lcd_wdat(*bmp++);
delayms(1);
}
lcd_wcmd(0x36); //写完数据,开图形显示
} /********************************************************** 清屏子函数 **********************************************************/
void clr_screen()
{
lcd_wcmd(0x34); //扩充指令操作
delayms(5);
lcd_wcmd(0x30); //基本指令操作
delayms(5);
lcd_wcmd(0x01); //清屏
delayms(5);
}
/********************************************************** 写字符串子函数 **********************************************************/
void wr_string(unsigned char str[])
{
unsigned char num = 0; while (str[num])
{
lcd_wdat(str[num++]); //写数据
delayms(150); //延时形成逐字显示效果
}
} /********************************************************** 主函数 **********************************************************/
void main()
{
delayms(100); //上电,等待稳定
lcd_init(); //初始化LCD while (1)
{
lcd_pos(1, 0); //设置显示位置为第一行
wr_string(DIS1);
lcd_pos(2, 0); //设置显示位置为第二行
wr_string(DIS2);
lcd_pos(3, 0); //设置显示位置为第三行
wr_string(DIS3);
lcd_pos(4, 0); //设置显示位置为第四行
wr_string(DIS4); delayms(5000); //停留2000***cdflag(); //屏幕闪烁 photodisplay(Photo1); //显示图片1
delayms(5000); //停留2000ms
clr_screen(); //清屏 }
} /*********************************************************/
巨大八爪鱼
学业有成8
unsigned char code DIS1[] =
{
"撕裂你!!!!!"
};
unsigned char code DIS2[] =
{
"把你撕成碎片!!"
};
unsigned char code DIS3[] =
{
"我是爱激的男朋友"
};
unsigned char code DIS4[] =
{
"不准欺负我女朋友"
};