Nokia3310 5110液晶显示(使用说明+C程序)
nokia5110_nokia3310中文数据手册
PCD8544�
1999 年 4 月 12 日
3
Philips 半导体
产品说明书
48x84点矩阵LCD控制/驱动
PCD8544
1 特征
单芯片 LCD 控制/驱动 48 行,84 列输出 显示数据 RAM 48*84 位 芯片集成: ——LCD 电压发生器(也可以使用外部电压供应) ——LCD偏置电压发生器 ——振荡器不需要外接元件(也可以使用外部时钟) 外部 RES(复位)输入引脚 串行界面最高 4.0Mbits/S CMOS 兼容输入 混合速率:48 逻辑电压范围 VDD 到 VSS:2.7V~3.3V 显示电压范围 VLCD 到 VSS: ——6.0~8.5V LCD内部电压发生器(充许电压发生器) ——6.0~9.0V LCD 外部电压供应(电压发生器关闭) 低功耗,适用于电池供电系统 关于 VLCD 的温度补偿 使用温度范围:-25~70℃
Philips 半导体
产品说明书
48x84点矩阵LCD控制/驱动
6.1.8 SCLK: 串行时钟线 输入:时钟信号: 0.0 ~ 4.0 Mbits/s. 6.1.9 D/C: 模式选择 输入:选择命令/地址或输入数据 6.1.10 SCE: 芯片使能 使能引脚充许输入数据,低电平有效。 6.1.11 OSC:振荡器
偏置电压 发生器
数据锁存器
移位寄存器 复位
RES OSC
VLCD1
发生器
VLCD
振荡器 显示数据存储器
(DDRAM) 48 × 84
VDD1 to VDD2 VSS1 to VSS2 T1 T2 T3 T4
时钟 发生器 显示 地址 计数器
地址计数器 数据 寄存器
I/O
PCD8544
NOKIA3510I液晶的51单片机部分驱动程序
#include <reg51.h>/* 雨亭电子代码测试环境:JME-2核心板+1T指令周期的STC单片机(51内核STC12LE5A60S2)+33M 晶振单片机工作电压3.3V程序默认IO连接方式:cs-P0^0; rest-P0^1; sdata-P1^5; sclk-P1^7;*///接口定义sbit cs=P0^0; //片选sbit rest=P0^1; //复位sbit sdata=P1^5; //数据sbit sclk=P1^7; //时钟unsigned char V er='A'; //驱动版本,默认为A版本,一共4个版本//8*12字符unsigned char code zifu[]={/*-- 文字: --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: ! --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00,/*-- 文字: " --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x28,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: # --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x28,0x28,0xFC,0x28,0x50,0xFC,0x50,0x50,0x00,0x00,/*-- 文字: $ --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x20,0x78,0xA8,0xA0,0x60,0x30,0x28,0xA8,0xF0,0x20,0x00,/*-- 文字: % --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x48,0xA8,0xB0,0x50,0x28,0x34,0x54,0x48,0x00,0x00,/*-- 文字: & --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x20,0x50,0x50,0x78,0xA8,0xA8,0x90,0x6C,0x00,0x00,/*-- 文字: ' --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: ( --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x04,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x04,0x00,/*-- 文字: ) --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x40,0x00,/*-- 文字: * --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x20,0xA8,0x70,0x70,0xA8,0x20,0x00,0x00,0x00,/*-- 文字: + --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x20,0x20,0x20,0xF8,0x20,0x20,0x20,0x00,0x00,0x00,/*-- 文字: , --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80,/*-- 文字: - --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: . --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,/*-- 文字: / --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x08,0x10,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x80,0x00,/*-- 文字: 0 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00,/*-- 文字: 1 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,/*-- 文字: 2 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x40,0x80,0xF8,0x00,0x00,/*-- 文字: 3 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,0x00,0x00,/*-- 文字: 4 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x10,0x30,0x50,0x50,0x90,0x78,0x10,0x18,0x00,0x00,/*-- 文字: 5 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0xF8,0x80,0x80,0xF0,0x08,0x08,0x88,0x70,0x00,0x00,/*-- 文字: 6 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x70,0x90,0x80,0xF0,0x88,0x88,0x88,0x70,0x00,0x00,/*-- 文字: 7 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0xF8,0x90,0x10,0x20,0x20,0x20,0x20,0x20,0x00,0x00,/*-- 文字: 8 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x88,0x70,0x00,0x00,/*-- 文字: 9 --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x48,0x70,0x00,0x00,/*-- 文字: : --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x20,0x00,0x00,/*-- 文字: ; --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x20,0x00,/*-- 文字: < --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00,/*-- 文字: = --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,/*-- 文字: > --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*/ /*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00,/*-- 文字: ? --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x20,0x00,0x20,0x00,0x00,/*-- 文字: @ --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x70,0x88,0x98,0xA8,0xA8,0xB8,0x80,0x78,0x00,0x00,/*-- 文字: A--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x20,0x20,0x30,0x50,0x50,0x78,0x48,0xCC,0x00,0x00,/*-- 文字: B --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xF0,0x48,0x48,0x70,0x48,0x48,0x48,0xF0,0x00,0x00,/*-- 文字: C --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x78,0x88,0x80,0x80,0x80,0x80,0x88,0x70,0x00,0x00,/*-- 文字: D --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xF0,0x48,0x48,0x48,0x48,0x48,0x48,0xF0,0x00,0x00,/*-- 文字: E --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x48,0xF8,0x00,0x00,/*-- 文字: F --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x40,0xE0,0x00,0x00,/*-- 文字: G --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x38,0x48,0x80,0x80,0x9C,0x88,0x48,0x30,0x00,0x00, /*-- 文字: H --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xCC,0x48,0x48,0x78,0x48,0x48,0x48,0xCC,0x00,0x00,/*-- 文字: I --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00,/*-- 文字: J --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0xE0,0x00,/*-- 文字: K --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xEC,0x48,0x50,0x60,0x50,0x50,0x48,0xEC,0x00,0x00,/*-- 文字: L --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x44,0xFC,0x00,0x00,/*-- 文字: M --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xD8,0xD8,0xD8,0xD8,0xA8,0xA8,0xA8,0xA8,0x00,0x00,/*-- 文字: N --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xDC,0x48,0x68,0x68,0x58,0x58,0x48,0xE8,0x00,0x00,/*-- 文字: O --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00,/*-- 文字: P--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xF0,0x48,0x48,0x70,0x40,0x40,0x40,0xE0,0x00,0x00,/*-- 文字: Q --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x70,0x88,0x88,0x88,0x88,0xE8,0x98,0x70,0x18,0x00,/*-- 文字: R --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xF0,0x48,0x48,0x70,0x50,0x48,0x48,0xEC,0x00,0x00,/*-- 文字: S --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x78,0x88,0x80,0x60,0x10,0x08,0x88,0xF0,0x00,0x00,/*-- 文字: T --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xF8,0xA8,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,/*-- 文字: U --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xCC,0x48,0x48,0x48,0x48,0x48,0x48,0x30,0x00,0x00,/*-- 文字: V --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xCC,0x48,0x48,0x50,0x50,0x30,0x20,0x20,0x00,0x00,/*-- 文字: W --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xA8,0xA8,0xA8,0x70,0x50,0x50,0x50,0x50,0x00,0x00,/*-- 文字: X --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xD8,0x50,0x50,0x20,0x20,0x50,0x50,0xD8,0x00,0x00,/*-- 文字: Y--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xD8,0x50,0x50,0x20,0x20,0x20,0x20,0x70,0x00,0x00,/*-- 文字: Z --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0xF8,0x90,0x10,0x20,0x20,0x40,0x48,0xF8,0x00,0x00,/*-- 文字: [ --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00,/*-- 文字: \ --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x00,0x00,/*-- 文字: ] --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00,/*-- 文字: ^ --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: _ --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,/*-- 文字: ` --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: a --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x38,0x48,0x3C,0x00,0x00,/*-- 文字: b --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0x70,0x00,0x00,/*-- 文字: c --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x40,0x40,0x38,0x00,0x00,/*-- 文字: d --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x18,0x08,0x08,0x38,0x48,0x48,0x48,0x3C,0x00,0x00,/*-- 文字: e --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x78,0x40,0x38,0x00,0x00,/*-- 文字: f --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x1C,0x20,0x20,0x78,0x20,0x20,0x20,0x78,0x00,0x00,/*-- 文字: g --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0x3C,0x48,0x30,0x40,0x78,0x44,0x38,/*-- 文字: h --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0xEC,0x00,0x00,/*-- 文字: i --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x70,0x00,0x00,/*-- 文字: j --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x10,0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0xE0,/*-- 文字: k --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xC0,0x40,0x40,0x5C,0x50,0x70,0x48,0xEC,0x00,0x00,/*-- 文字: l --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00,/*-- 文字: m --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0xF0,0xA8,0xA8,0xA8,0xA8,0x00,0x00,/*-- 文字: n --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0xEC,0x00,0x00,/*-- 文字: o --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x30,0x00,0x00,/*-- 文字: p --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0x70,0x40,0xE0,/*-- 文字: q --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x48,0x48,0x38,0x08,0x1C,/*-- 文字: r --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0xD8,0x60,0x40,0x40,0xE0,0x00,0x00,/*-- 文字: s --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x00,0x00,0x00,0x00,0x78,0x40,0x30,0x08,0x78,0x00,0x00, /*-- 文字: t --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00,/*-- 文字: u --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0xD8,0x48,0x48,0x48,0x3C,0x00,0x00,/*-- 文字: v --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x00,0x00,/*-- 文字: w --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0xA8,0xA8,0x70,0x50,0x50,0x00,0x00,/*-- 文字: x --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0xD8,0x50,0x20,0x50,0xD8,0x00,0x00,/*-- 文字: y --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x20,0xC0,/*-- 文字: z --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x00,0x00,0x00,0x00,0x78,0x10,0x20,0x20,0x78,0x00,0x00,/*-- 文字: { --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x00,0x18,0x10,0x10,0x10,0x20,0x10,0x10,0x10,0x10,0x18,0x00,/*-- 文字: | --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,/*-- 文字: } --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x00,0x60,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x60,0x00,/*-- 文字: ~ --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 宽度不是8的倍数,现调整为:宽度x高度=8x12 --*/0x40,0xA4,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};//16*16汉字unsigned char code hanzi[]={/*---------------雨----------------*/0x00,0x4F,0xFE,0x4,0x7,0xFC,0x66,0x45,0x54,0x44,0x46,0x64,0x55,0x44,0x44,0x45,0xC0,0x00,/*---------------亭----------------*/0x04,0x07,0xFC,0x00,0x01,0xF8,0x10,0x8F,0xFE,0x80,0x23,0xF8,0x04,0x00,0x40,0x1C, 0x00,0x00,/*---------------电----------------*/0x04,0x00,0x44,0x7F,0xE4,0x44,0x7F,0xC4,0x44,0x44,0x47,0xFC,0x44,0x00,0x42,0x03,0xE0,0x00,/*---------------子----------------*/0x7F,0xC0,0x08,0x01,0x00,0x60,0x04,0x4F,0xFE,0x04,0x00,0x40,0x04,0x00,0x40,0x1C,0x00,0x00,/*---------------我----------------*/0x0A,0x8F,0x24,0x12,0x0F,0xFE,0x12,0x01,0x64,0x3A,0x8D,0x10,0x13,0x21,0xCA,0x70, 0x60,0x00,/*---------------是----------------*/0x1F,0x81,0x08,0x1F,0x81,0x08,0x1F,0x80,0x00,0xFF,0xE2,0x40,0x37,0xC4,0xC0,0x87,0xE0,0x00,/*---------------企----------------*/0x04,0x00,0x60,0x09,0x01,0x08,0x24,0x6C,0x40,0x17,0x81,0x40,0x14,0x01,0x40,0xFF,0xE0,0x00,/*---------------鹅----------------*/0x30,0x8D,0xBC,0x52,0x4F,0xB4,0x52,0xC7,0x60,0xDB,0xE5,0x02,0x6B,0xE4,0xA2,0xC6, 0xC0,0x00,/*---------------我----------------*/0x0A,0x8F,0x24,0x12,0x0F,0xFE,0x12,0x01,0x64,0x3A,0x8D,0x10,0x13,0x21,0xCA,0x70, 0x60,0x00,/*---------------怕----------------*/0x21,0x02,0x20,0x27,0xEB,0x42,0xAC,0x2A,0x42,0x27,0xE2,0x42,0x24,0x22,0x42,0x27, 0xE0,0x00,/*---------------谁----------------*/0x45,0x02,0x48,0x0F,0xE0,0xC8,0xD7,0xE4,0x48,0x44,0x84,0x7E,0x54,0x86,0x7E,0x04,0x00,0x00,/*-------------------------------*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};//40*40图片const unsigned char gImage_1[3708] = { 0X00,0X10,0X32,0X00,0X25,0X00,0X01,0X1B,0XA1,0X3A,0X05,0X5C,0X03,0X2A,0X83,0X4B,0X9E,0XEF,0XA5,0X4B,0XE1,0X53,0X41, } ;/*这里删掉了部分代码*/void delayms(unsigned int ii)//1ms延时函数{unsigned int i,x;for (x=0;x<ii;x++){for (i=0;i<100;i++);}}void send(unsigned char value, unsigned char cd) //写8位数据{unsigned char i,dt;cs=0;sclk=0;if(cd == 0)sdata=0;elsesdata=1;sclk=1;dt=value;for(i=0;i<8;i++){sclk=0;if(dt&0x80)sdata=1;elsesdata=0;dt=dt<<1;sclk=1;}cs=1;}void readdata() //读数据{unsigned char i,j;unsigned char ch[6];send(0x09, 0); // 读数据cs=0;sclk=0;for (i=0;i<6;i++){ch[i]=0;for (j=0;j<8;j++){sclk=1;if (sdata==0){ch[i]=ch[i]|(1<<(7-j));}sclk=0;}}switch(ch[0]){case 255:V er='A';break;case 127:V er='B';break;case 0:if(ch[1]+ch[2]+ch[3]==0){V er='D';}else{V er='C';}break;}cs=1;void LCD_Initialize() //LCD初始化{unsigned char i;rest=1;cs=1;sdata=0;sclk=1;rest=0;delayms(50);rest=1;delayms(50);send(0x00, 0); // NOPdelayms(5);send(0x01, 0); // LCD Software Resetdelayms(5);send(0xC6, 0); // Initial Escapesend(0xB9, 0); // Refresh setsend(0x00, 1);readdata(); //读出数据send(0xB5, 0); // Gamma Curve Setsend(0x01, 1);send(0xbd, 0); //common driver output select//很重要的if(V er=='D'){send(0x04, 1);}else{send(0x00, 1);}send(0xBE, 0); // Power Controlsend(0x03, 1);send(0x11, 0); // Sleep outsend(0xBA, 0); // Power Controlsend(0x7F, 1);send(0x03, 1);send(0x36, 0); // 扫描方式if (V er=='A'){send(0x00|0x08,1); //RGB}else{send(0x00,1); //RGB}send(0xB7, 0); // Temperature gradient setfor(i=0; i<14; i++){send(0, 1);}send(0x29, 0); //display ONsend(0x03, 0); // Booster V oltage ONdelayms(20); // Booster V oltage stabilisieren lassen send(0x20, 0); //display inversion OFFsend(0x25, 0); // Write contrastswitch(V er) //对比度设置{case 'A':send(70, 1); //对比度设置break;case 'B':send(67, 1); //对比度设置break;case 'C'://send(74, 1);send(66, 1);// send(64, 1); //对比度设置break;case 'D': //对比度设置send(39, 1);break;}}//************************//颜色模式设置:color=1为4096色模式// :color=0为256色模式//************************void LCD_ColorSet(unsigned char Color){if (Color==1) {send(0x3a, 0); //interface pixel formatsend(0x03, 1); //0x03 为4096色,0x02为256色}else{send(0x3a, 0); //interface pixel formatsend(0x02, 1); //0x03 为4096色,0x02为256色send(0x2d, 0); //调色板设置if (V er=='B'||V er=='C'){//redsend(~0x00, 1);send(~0x02, 1);send(~0x03, 1);send(~0x04, 1);send(~0x05, 1);send(~0x06, 1);send(~0x08, 1);send(~0x0f, 1);//greensend(~0x00, 1);send(~0x02, 1);send(~0x03, 1);send(~0x04, 1);send(~0x05, 1);send(~0x06, 1);send(~0x08, 1);send(~0x0f, 1);//bluesend(~0x00, 1);send(~0x03, 1);send(~0x06, 1);send(~0x0f, 1);}else{//redsend(0x00, 1);send(0x02, 1);send(0x03, 1);send(0x04, 1);send(0x05, 1);send(0x06, 1);send(0x08, 1);send(0x0f, 1);//greensend(0x00, 1);send(0x02, 1);send(0x03, 1);send(0x04, 1);send(0x05, 1);send(0x06, 1);send(0x08, 1);send(0x0f, 1);//bluesend(0x00, 1);send(0x03, 1);send(0x06, 1);send(0x0f, 1);}}}void addset(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2) //坐标设置4个参数依次为开始X,开始Y,结束x,结束Y{send(0x2a,0 );//column address setsend(x1,1 );send(x2,1 );send(0x2B,0 );//page address setsend(y1,1 );send(y2,1 );send(0x2C,0 );//memory write}//************************//清屏:color=1为4096色模式清屏// :color=0为256色模式清屏//************************void LCD_Clear(unsigned int value,unsigned char Color){unsigned char x, y;addset(0,0,97,66);if (Color==1){for(y = 0; y < 67; y ++){for(x = 0; x < 49;x ++){ send(value>>4,1);send(((value&0x0f)<<4)|(value>>8),1);send(value,1);}}}else{for(y = 0; y < 67; y ++){for(x = 0; x < 98; x ++){send(value,1);}}}}//在指定位置显示一个字符(8*12大小)//dcolor为内容颜色,gbcolor为背静颜色void showzifu(unsigned char x,unsigned char y,unsigned char value,unsigned char dcolor,unsigned char bgcolor){unsigned char i,j;unsigned char *temp=zifu;addset(x,y,x+7,y+11); //设置区域temp+=(value-32)*12;for(j=0;j<12;j++){for(i=0;i<8;i++){if((*temp&(1<<(7-i)))!=0){send(dcolor,1);}else{send(bgcolor,1);}}temp++;}}//在指定位置显示一个字符串(8*12大小)//dcolor为内容颜色,gbcolor为背静颜色void showzifustr(unsigned char x,unsigned char y,unsigned char *str,unsigned char dcolor,unsigned char bgcolor){unsigned char x1,y1;x1=x;y1=y;while(*str!='\0'){showzifu(x1,y1,*str,dcolor,bgcolor);x1+=7;str++;}}//在指定位置显示一个汉字(12*12大小)//dcolor为内容颜色,gbcolor为背静颜色void showhanzi(unsigned char x,unsigned char y,unsigned char value,unsigned char dcolor,unsigned char bgcolor){unsigned char i,j;unsigned char *temp=hanzi;addset(x,y,x+11,y+11); //设置区域temp+=value*18;for(j=0;j<18;j++){for(i=0;i<8;i++){if((*temp&(1<<(7-i)))!=0){send(dcolor,1);}else{send(bgcolor,1);}}temp++;}}int main(void){int i;//256色//0b11100000 0xe0 red//0b00011100 0x1c green//0b00000011 0x03 blueLCD_Initialize(); //LCD初始化LCD_ColorSet(0); //0为256色模式,1为4096色模式LCD_Clear(255,0); //清屏addset(28,0,67,39); //设置起止坐标,4个参数依次为开始X,开始Y,结束x,结束Yfor(i=0;i<1600;i++){send(img[i],1);}showhanzi(0,40,4,0xe0,255); //我showhanzi(14,40,5,0xe0,255); //是showhanzi(28,40,6,0xe0,255); //乞showhanzi(42,40,7,0xe0,255); //鹅showhanzi(56,40,8,0xe0,255); //我showhanzi(70,40,9,0xe0,255); //怕showhanzi(84,40,10,0xe0,255); //谁showhanzi(0,5,0,0x03,255); //雨showhanzi(14,5,1,0x03,255); //亭showhanzi(0,19,2,0x03,255); //电showhanzi(14,19,3,0x03,255); //子showzifustr(5,55,"NOKIA 3510I-",0x03,255); //显示字符串showzifu(90,55,V er,0x03,255); //显示驱动版本showzifustr(68,5,"GOOD",0,255); //显示字符串showzifustr(75,17,"LCD",0,255); //显示字符串while(1){LCD_Initialize(); //LCD初始化LCD_ColorSet(0); //0为256色模式,1为4096色模式LCD_Clear(255,0); //清屏addset(28,0,67,39); //设置起止坐标,4个参数依次为开始X,开始Y,结束x,结束Yfor(i=0;i<1600;i++){send(img[i],1);}showhanzi(0,40,4,0xe0,255); //我showhanzi(14,40,5,0xe0,255); //是showhanzi(28,40,6,0xe0,255); //乞showhanzi(42,40,7,0xe0,255); //鹅showhanzi(56,40,8,0xe0,255); //我showhanzi(70,40,9,0xe0,255); //怕showhanzi(84,40,10,0xe0,255); //谁showhanzi(0,5,0,0x03,255); //雨showhanzi(14,5,1,0x03,255); //亭showhanzi(0,19,2,0x03,255); //电showhanzi(14,19,3,0x03,255); //子showzifustr(5,55,"NOKIA 3510I-",0x03,255); //显示字符串showzifu(90,55,V er,0x03,255); //显示驱动版本showzifustr(68,5,"GOOD",0,255); //显示字符串showzifustr(75,17,"LCD",0,255); //显示字符串delayms(15000);}}。
51单片机的液晶显示温度计程序
51单片机的液晶显示温度计程序51单片机的液晶显示温度计程序#include<reg51.h>#include <intrins.h>sbit RST = P2^0;sbit CLK = P2^1;sbit DQ = P2^2;sbit TSOR = P2^3;sbit ALERT =P2^4;sbit RS = P2^7;sbit RW = P2^6;sbit EN = P2^5;/*------------------------------------------全局变量-------------------------------------------------------*/static unsigned char temp1,temp2; //温度值的整数部分、小数部分static unsigned char pos,posset; //数字电位器电位值、设定值static unsigned char min,sec; //分钟、秒static unsigned char count; //Timer0中断计数static unsigned char minset; //设定的分钟数static unsigned char status1,status2; //状态标志bit stop,timeover; //定时停止、结束static char line0[] =" 00:00 ";static char line1[] =" . CW";/*-------------------------------------------------------------------------------------------------------------*/void InitInterupt();void KeyboardDelay();/*-------------------------------------------LCD驱动函数------------------------------------------------*/void DelayL();void DelayS();void WriteCommand(unsigned char c);void WriteData(unsigned char c);void ShowChar(unsigned char pos,unsigned char c); void ShowString(unsigned char line,char *ptr);void InitLcd();/*----------------------------------------------键盘-程序--------------------------------------------------*/unsigned char GetKey();/*---------------------------------------------数字温度计驱动-------------------------------------------*/void ChangePos(bit sel,unsigned char pos1,unsigned char pos2);/*------------------------------------------温度传感器驱动----------------------------------------------*/void Delay15();void Delay60();void Delay100ms();void Write0TS();void Write1TS();bit ReadTS();void ResetTS();void WriteByteTS(unsigned char byte); unsigned char ReadByteTS();void InitTS();void GetTempTS();/*-------------------------------------------------主程序---------------------------------------------------*/void main (void) {char code str1[] =" Hello World! ";char code str2[] =" 2002-10-20 "; unsigned char i; SP=0x50;ALERT=0; //报警灯灭TSOR=1; //1-wire总线释放DelayL();InitLcd(); //初始化LCDDelayL();ShowString(0,str1); //启动画面ShowString(1,str2);for(i=0;i<15;i++)Delay100ms();InitInterupt(); //初始化中断设置minset=10; //缺省定时10分钟posset=0; //缺省电位器值0min=minset; //初始化数据pos=posset;sec=0;count=0;P1=0xF0;status1=0;status2=0;stop=1;timeover=0; ChangePos(0,255-pos,255-pos); //设置电位器InitTS(); //初始化温度计while(1) //循环显示温度值{GetTempTS();line1[0]=0x20;i=temp1;if(i>39) //超过40摄氏度,告警灯亮ALERT=1;if(i>99) //超过100摄氏度,显示温度的百位{line1[0]=0x31;i-=100;}line1[1]=i/10+0x30; //显示温度的十位line1[2]=i%10+0x30; //显示个位line1[4]=temp2+0x30; //显示小数位if(timeover) //若定时结束,则电位器缓慢复0{for(;pos>0;pos--){ChangePos(0,255-pos,255-pos);_nop_();_nop_();}timeover=0;posset=0;}if(pos>posset) //若按键修改电位器位置{for(;pos>posset;pos--) //则缓变到设定值{ChangePos(0,255-pos,255-pos);_nop_();_nop_();}ChangePos(0,255-pos,255-pos);}else if(pos<posset){for(;pos<posset;pos++){ChangePos(0,255-pos,255-pos);_nop_();_nop_();}ChangePos(0,255-pos,255-pos);}i=pos;line1[9]=0x20; //显示电位器等级值if(i>99){line1[9]=i/100+0x30;i=i%100;}line1[10]=i/10+0x30;line1[11]=i%10+0x30;ShowString(1,line1);line0[5]=min/10+0x30; //显示时间line0[6]=min%10+0x30;line0[8]=sec/10+0x30;line0[9]=sec%10+0x30;ShowString(0,line0);Delay100ms();}}void InitInterupt(){TMOD=0x21; //初始化中断设置TL1=0xFD;TH1=0xFD;PX0=1;EA=1;ES=1;PCON=0;TR1=1;SCON=0x50;TL0=0x00; //定时0.05mTH0=0x4C;ET0=1; EX0=1;IT0=1;}void KeyboardDelay() //按键中断延时{unsigned char i,j;i=0x40;j=0xFF;while(i--)while(j--);}/*--------------------------------------------中断处理-----------------------------------------------------*/Int0_process() interrupt 0 using 0{unsigned char key;unsigned char keycode[]= "TP";unsigned char step[3]={1,2,5};EA=0;key=GetKey(); //获得按键值switch(key){case 0:stop=!stop;min=minset;sec=0;break;case 1:case 2:case 3:if(stop){minset+=step[key-1];if(minset>60)minset=0;min=minset;}break;case 5:case 6:case 7:if(stop){minset-=step[key-5]; if(minset>60) minset=0;min=minset;}break;case 9:case 10:case 11:posset+=step[key-9];break;case 13:case 14:case 15:posset-=step[key-13];break;default:break;}TR0=!stop;KeyboardDelay();P1=0xF0;EA=1;}Timer0_process() interrupt 1 using 0{EA=0;TR0=0;TL0=0x00;TH0=0x4C;count++;if(count==20) //如果到累计定时到达1s {if(sec==0) //定时处理{if(min==0) //总定时到,则置结束标志timeover=1;else{min--;sec=59;}}elsesec--;count=0;}TR0=1;EA=1;}/*--------------------------------------LCD驱动子程序--------------------------------------------------*/void DelayL(){unsigned char i,j;i=0xF0;j=0xFF;while(i--)while(j--);}void DelayS(){unsigned char i;i=0x1F;while(i--);}void WriteCommand(unsigned char c) {DelayS();EN=0;RS=0;RW=0;_nop_();EN=1;P0=c;EN=0;}void WriteData(unsigned char c){DelayS();EN=0;RS=1;RW=0;_nop_();EN=1;P0=c;EN=0;RS=0;}void ShowChar(unsigned char pos,unsigned char c) {unsigned char p;if(pos>=0x10)p=pos+0xB0;elsep=pos+0x80;WriteCommand(p);WriteData(c);}void ShowString(unsigned char line,char *ptr){unsigned char l,i;l=line<<4;for(i=0;i<16;i++)ShowChar(l++,*(ptr+i));} void InitLcd(){DelayL();WriteCommand(0x38);WriteCommand(0x38);WriteCommand(0x06);WriteCommand(0x0C);WriteCommand(0x01);WriteCommand(0x80);}/*---------------------------------------------键盘子程序-------------------------------------------------*/ unsigned char GetKey(){unsigned k,t,i,j;k=P1;k=k&0xF0;i=0;while((k&0x10)&&i<4) {i++;k=k>>1;}k=0x01;j=0;while(j<4){P1=0xFF^k;_nop_();t=P1;t=t^0xFF;t=t&0xF0;if(t)break;j++;k=k<<1;}k=j*4+i;return k;}/*-----------------------------------------数字温度计驱动子程序--------------------------------------*/void ChangePos(bit sel,unsigned char pos1,unsigned char pos2){ unsigned char i;RST=0;DQ=0;CLK=0;RST=1;DQ=sel;_nop_();CLK=1;_nop_();CLK=0;for(i=0;i<8;i++) {if(pos1&0x80)DQ=1;elseDQ=0;_nop_();CLK=1;_nop_();CLK=0;pos1=pos1<<1; }for(i=0;i<8;i++) {if(pos2&0x80)DQ=1;elseDQ=0;_nop_();CLK=1;_nop_();CLK=0;pos2=pos2<<1;}RST=0;}/*------------------------------------------温度传感器子程序-------------------------------------------*/void Delay100ms() //延时100ms {unsigned char i,j,k;for(i=0;i<8;i++)for(j=0;j<25;j++)for(k=0;k<250;k++);}void Delay15() //延时15us{unsigned char i;for(i=0;i<8;i++);}void Delay60() //延时60us{unsigned char i;for(i=0;i<30;i++);}void Write0TS() //写bit 0 {TSOR=1;TSOR=0;Delay15();Delay15();Delay15();Delay15();TSOR=1;_nop_();_nop_();}void Write1TS() //写bit 1 {TSOR=1;TSOR=0;_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();TSOR=1;_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();Delay15();Delay15();Delay15(); }bit ReadTS() {bit b;TSOR=1;TSOR=0; _nop_();_nop_();_nop_();_nop_();TSOR=1;_nop_();_nop_();_nop_();_nop_();_nop_();b=TSOR;Delay15();Delay15();Delay15();_nop_();_nop_();return b;}void ResetTS() //复位{unsigned char i; TSOR=1;TSOR=0;for(i=0;i<8;i++)Delay60();TSOR=1;while(TSOR);for(i=0;i<8;i++)Delay60();}void WriteByteTS(unsigned char byte) //写一个字节(byte){unsigned char i;for(i=0;i<8;i++){if(byte&0x01)Write1TS();elseWrite0TS();byte=byte>>1;}}unsigned char ReadByteTS() //读一个字节(byte){unsigned char i,j;bit b;j=0;for(i=0;i<8;i++){b=ReadTS();if(b)j+=1;j=_cror_(j,1);}return j;}void InitTS() //初始化温度转换{ResetTS();WriteByteTS(0xCC);WriteByteTS(0x4E);WriteByteTS(0x64);WriteByteTS(0x8A);WriteByteTS(0x1F);}void GetTempTS() //获取温度{ResetTS();WriteByteTS(0xCC);WriteByteTS(0x44);Delay100ms();ResetTS();WriteByteTS(0xCC);WriteByteTS(0xBE);temp2=ReadByteTS();temp1=ReadByteTS();ReadByteTS();ReadByteTS();ReadByteTS();ReadByteTS();ReadByteTS();ReadByteTS();ReadByteTS();temp1=temp1<<4;temp1+=(temp2&0xF0)>>4;temp2=(temp2&0x0F)?5:0;}液晶显示温度计程序。
Nokia5110程序
#include <hidef.h> /* common defines and macros */#include "derivative.h" /* derivative-specific definitions */#define uchar unsigned char#define uint unsigned int#define lcd12864_date PORTB //数据口#define lcd12864_rs PTT_PTT5// PTT_PTT5; //寄存器选择输入#define lcd12864_rw PTT_PTT3 //液晶读/写控制#define lcd12864_e PTT_PTT2 //液晶使能控制#define DQ PORTA_PA0 // 定义DQ引脚为P3.3 #define DQ_HIGH() DDRA=0 //设置数据口为输入#define DQ_LOW() DDRA=1;DQ=0; //设置数据口为输出//uint temp; //温度值variable of temperature uchar A1,A2,A3;void delay2(uint i);void Init_Ds18b20(void);uchar Read_One_Byte();void Write_One_Byte(uchar dat);uint Get_Tmp();void DisplayTemp(uint temp) ;void delay(unsigned int t){uint i,j;for(i=t;i>0;i--)for(j=1000;j>0;j--);}void lcd12864_write_cmd(unsigned char command) //写指令{lcd12864_rs=0;lcd12864_rw=0;lcd12864_e=0;lcd12864_date=command;delay(5);lcd12864_e=1;lcd12864_e=0;delay(5);}void lcd12864_write_data(unsigned char data) // 写数据写入一个字符{lcd12864_rs=1;lcd12864_rw=0;lcd12864_e=0;lcd12864_date=data;delay(5);lcd12864_e=1;lcd12864_e=0;delay(5);}void lcd12864_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{x=0x98;}pos=x+y-1;lcd12864_write_cmd(pos); //显示地址}void io_init(){lcd12864_write_cmd(0x30); //基本指令操作lcd12864_write_cmd(0x0C); //显示开,关光标lcd12864_write_cmd(0x01); //清除LCD的显示内容位置计数器调整为0x00 }void lcd12864_wrtie_string( char *str) //写字符串{while(*str!='\0') //未结束{lcd12864_write_data(*str++);}}void init_LCD(){delay(20);lcd12864_write_cmd(0x30);delay(20);lcd12864_write_cmd(0x30);delay(20);lcd12864_write_cmd(0x0c);//开显示,不显示光标,且不闪烁delay(20);lcd12864_write_cmd(0x01); //清屏delay(20);lcd12864_write_cmd(0x06); //每次写入数据后地址指针加1delay(20);}/**/void Display1(){lcd12864_pos(1,2);lcd12864_wrtie_string("温度调节系统");lcd12864_pos(2,1);lcd12864_wrtie_string("菜单1:当前温度");lcd12864_pos(3,1);lcd12864_wrtie_string("菜单2:目标温度");lcd12864_pos(4,1);lcd12864_wrtie_string("菜单3:温度曲线");}void Display2(){lcd12864_pos(1,2);lcd12864_wrtie_string("温度调节系统");lcd12864_pos(2,1);lcd12864_wrtie_string("当前温度:**度");lcd12864_pos(3,1);lcd12864_wrtie_string("目标温度:**度");lcd12864_pos(4,2);lcd12864_wrtie_string(" Welcome ! ");}void main(void){delay(5);DDRB=0xff;DDRT=0xff;// io_init();init_LCD();lcd12864_pos(2,2);lcd12864_wrtie_string(" Welcome To ! ");lcd12864_pos(3,2);lcd12864_wrtie_string("温度调节系统");delay(2000);lcd12864_write_cmd(0x01); //清屏delay(20);while(1){DisplayTemp(Get_Tmp());lcd12864_pos(2,3);lcd12864_write_data(0x30+A1);lcd12864_pos(2,4);lcd12864_write_data(0x30+A2);lcd12864_pos(2,5);lcd12864_write_data(0x2e);lcd12864_pos(2,6);lcd12864_write_data(0x30+A3);/*Display1() ; */}}/*************精确延时函数*****************/ void delay2(unsigned int i){i=10*i;while(--i);}/****************************************** 此延时函数针对的是12Mhz的晶振delay(0):延时518us 误差:518-2*256=6delay(1):延时7us (原帖写"5us"是错的)delay(10):延时25us 误差:25-20=5delay(20):延时45us 误差:45-40=5delay(100):延时205us 误差:205-200=5delay(200):延时405us 误差:405-400=5*******************************************//*****************DS18B20******************/void Init_Ds18b20(void) //DS18B20初始化send reset and initialization command{char presence=1;while(presence){//DQ = 1; //DQ复位,不要也可行。
关于Nokia5110液晶显示黑屏或者白屏的解决办法
关于Nokia5110液晶显示黑屏或者白屏的解决办法——艾米电子赵亮1/3/2013Nokia5110是一款非常经典的液晶显示模块,本人从07年开始接触这款屏,至今已经有5年多的时间。
这里有几点调试的心得体会跟大家分享一下。
(1)该屏目前都是拆机件,没有全新,只不过是产品的成色问题。
(2)驱动的话,目前估计任何处理器的版本都能找到了,我这里提供51的程序下载,如有需要请与我联系。
(3)导电胶条,很多人都认为全新的导电胶条最好,从我的经验来讲,这个胶条有一个对应关系有的时候换一换就搞定了。
这是我测试的经验,一般测试100个屏,首次成功率有80%左右,剩余的20个屏调换一下液晶底板重新再测试,还能有10个以上调试通过,最后剩余的几个通过换导电胶条的方式也能搞定。
我测试的成功率目前是95%以上,从我手里经过的每一个屏都亲自测试过。
年销量大约8000片左右。
(4)就像我在上一条中提到的,这个屏是通过导电胶条接触的,在运输过程中因震动等原因造成的接触松动是常有的事,所以网友在测试的时候,一定首先要确保液晶接触良好,可以通过手轻微的碰一碰观察看看效果,另外可以拆下来重新装上也可以的。
后面有四个金属固定卡槽,用镊子或者尖嘴螺丝刀一碰就可以查下来,然后调整一下位置重新装上。
以上几点不是我今天要说的重点,最近几次通过客户反映、自己总结以及与供货商沟通发现一个规律,为此总结一下,希望能够解决部分问题。
主要是针对一部分应显示黑屏的问题。
以前一直没注意,其实这款液晶初始化的时候有参数可以调整对比度。
如图1所示,基本上市场上的液晶可以分为两种:(1)以LPH7366-x开头的一行字符信息,如图中1~5。
(2)不带有这行信息的如图中6所示。
图 1 5110液晶实物图一般来讲,图中6的液晶比较好驱动,用默认程序就可以点亮,而LPH7366-x开头的液晶有的时候会遇到黑屏或者有黑影的情况,此时可以通过驱动程序初始化进行调整:LCD_write_byte(0xc8, 0); // 设置偏置电压LCD_write_byte(0x06, 0); // 温度校正LCD_write_byte(0x13, 0); // 1:48图 2 液晶初始化参数如果遇到黑屏,可以调整第1行程序的参数,将0xc8进行调整,范围为0x80~0xFF,可以通过二分法进行凑配,比如设置0xaa或者0xee先看看效果,然后逐渐摸索规律进行修改。
c51单片机程序-nokia5110液晶显示
高电平表示数据输入 ,低电平表示命令输入 #define LCD_CLK P15 上升沿写入 #define LCD_DIN P23 #define LCD_BL P17 高电平点亮,低电平关闭 code unsigned char { ascii_dot[] = // ASCII 表
0x00,0x00,0x00,0x00,0x00, // - 0x00,0x00,0x5F,0x00,0x00, // -!0x00,0x07,0x00,0x07,0x00, // -"0x14,0x7F,0x14,0x7F,0x14, // -#0x24,0x2E,0x7B,0x2A,0x12, // -$0x23,0x13,0x08,0x64,0x62, // -%0x36,0x49,0x56,0x20,0x50, // -&0x00,0x04,0x03,0x01,0x00, // -'0x00,0x1C,0x22,0x41,0x00, // -(0x00,0x41,0x22,0x1C,0x00, // -)0x22,0x14,0x7F,0x14,0x22, // -*0x08,0x08,0x7F,0x08,0x08, // -+0x40,0x30,0x10,0x00,0x00, // -,0x08,0x08,0x08,0x08,0x08, // --0x00,0x60,0x60,0x00,0x00, // -.0x20,0x10,0x08,0x04,0x02, // -/0x3E,0x51,0x49,0x45,0x3E, // -00x00,0x42,0x7F,0x40,0x00, // -10x62,0x51,0x49,0x49,0x46, // -20x21,0x41,0x49,0x4D,0x33, // -30x18,0x14,0x12,0x7F,0x10, // -40x27,0x45,0x45,0x45,0x39, // -50x3C,0x4A,0x49,0x49,0x31, // -60x01,0x71,0x09,0x05,0x03, // -70x36,0x49,0x49,0x49,0x36, // -80x46,0x49,0x49,0x29,0x1E, // -90x00,0x36,0x36,0x00,0x00, // -:-
诺基亚5110液晶显示器应用课程设计
单片机原理及应用课程设计电气工程学院一、课程设计任务书1.课程设计项目诺基亚5110液晶显示器应用。
2.设计内容1)设计诺基亚5110液晶显示器应用的总体设计方案;2)以MCS-51系列单片机为核心器件和诺基亚5110液晶显示器组成液晶显示硬件系统;3)系统程序编制与调试;4)电路系统的综合调试;5)撰写课程设计论文;6)完成课程设计论文答辩。
3.设计要求1)以STC89C51单片机为控制核心,对诺基亚5110液晶显示器进行控制。
编程使得在LCD显示器上显示字符,如多行滚动显示:“吉林工程技术师范学院”“电气工程学院”。
等字符,还可以显示别的文字;2)单片机课程设计题目的硬件电路、程序由学生自行设计完成。
3)液晶显示器上要显示出设计人的班级,组长的学号等信息。
4.设计进度(2011年6月13日至2011年6月24日)时间设计内容第1-2天查阅资料,方案比较、设计与论证,理论分析与计算第3-5天硬件电路调试第6-8天系统调试第9-10天书写报告、答辩5.设计地点新实验楼323微机实验室二.参考资料[1]李广弟,朱月秀,王秀山编著.单片机基础. 北京:北京航空航天大学出版社,2001[2] 何立民编著.MCS-51系列单片机应用系统设计系统配置与接口技术.北京:北京航空航天大学出版社,1999[3] 蔡美琴等编著.MCS-51 单片机系统及应用.北京:高等教育出版社.1992二、评语及成绩成绩:指导教师:单片机原理及应用课程设计班级:自动化0845 姓名:刘旭阳学号: 11 号指导教师:方健撰写日期: 2011年6月23日Nokia LCD多功能显示摘要液晶显示器件[1](LCD)是一种高新技术的基础元器件。
它利用液晶的各种电光效应,把液晶对电场、磁场、光线和温度等外界条件的变化在一定条件下转换为可视信号而制成的显示器。
液晶显示器具有低电压、低功耗的特点,与CMOS集成电路相匹配.电池作为电源,适合于便携式显示。
LCD5110_Basic库使用教程
液晶(诺基亚LCD3310)驱动电路及程序
诺基亚3310液晶是一种OEM产品48X84 pixels matrix LCD controller/driver生产厂家Philips, 型号为:PCD8544可显示84*48点,被评为性价比最好的AVR液晶3310lcd驱动电路:Vdd接3.3V(注意:工作电压是3.3V)或者如图接(1、接100欧姆电阻接5V 2、接二极管再接地)V out接4.7uF电容后接地,电容作用是调对比度GND接地其它的接普通IO口编码显示原理:LCD3310屏幕由84*48个点组成,划分为84列*6行个显示单元,每一个显示单元由1*8个点组成,编程控制显示时按坐标定位,X轴从左到右为0、1、。
83,Y轴从上到下为0、1.。
5,每一个显示单元用一个十六进制0x**控制,0x**转换成二进制后是8个01位,每一个显示单元从上到下为点1到点8,分别对应二进制数的最低到最高位,为1的显示黑点,为0的不显示下面将要讲到的字符显示是用六个连续的显示单元控制显示的,将会显示符号*所以我们可以自由的显示字母、汉字、图片,只要将对应的十六进制控制码写入LCD即可,汉字和图片的控制码可借助于专用的字模生成软件生成。
Pin Signal Description Port1:VDDPower Input. Logic supply voltage range VDD to GND : 2.7 to 3.3 V2:SCLKSerial clock. Input for the clock signal: 0.0 to 4.0 Mbits/s.3:SDINSerial data. Input for the data line.4:D/CMode Select. To select either command/address or data input.5:SCEChip enable input. The enable pin allows data to be clocked in. The signal is active LOW.6:GNDGround7:VOUTOuptut voltage. Add external 1-10 uF electrolytic capacitor from VOUT to GND8:RESExternal reset. This signal will reset the device and must be applied to properlyinitialize the chip. The signal is active LOW.程序:(完整可运行)下面的程序是针对飞思卡尔的十六位单片机MC9S12XS128开发的用于其它MCU时只要将端口改一下,就可移植#include <hidef.h> /* common defines and macros */#include "derivative.h" /* derivative-specific definitions */#define sclk PTM_PTM0 //时钟#define sdin PTM_PTM1 //数据#define dc PTM_PTM2 //1写数据,0写指令#define sce PTP_PTP4 //片选#define res PTP_PTP7 //复位byte const mask_table[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};void Initlcd(void);//LCD初始化void write_byte(byte dd,byte a);//写一个字节到LCDvoid qp(void);//清屏void setadd(byte a,byte d);//设置坐标void DelaymS(word delay);//延时byte const dal1[][6]={//字符显示对应的二维十六进制数组,本程序中没有用到{0x00,0x00,0x00,0x00,0x00,0x00}, // 0位显示空白{0x00,0x00,0x00,0x00,0x00,0x00}, // 1{0x00,0x00,0x00,0x00,0x00,0x00}, // 2{0x00,0x00,0x00,0x00,0x00,0x00}, // 3{0x00,0x00,0x00,0x00,0x00,0x00}, // 4{0x00,0x00,0x00,0x00,0x00,0x00}, // 5{0x00,0x00,0x00,0x00,0x00,0x00}, // 6{0x00,0x00,0x00,0x00,0x00,0x00}, // 7{0x00,0x00,0x00,0x00,0x00,0x00}, // 8{0x00,0x00,0x00,0x00,0x00,0x00}, // 9{0x00,0x00,0x00,0x00,0x00,0x00}, // 10{0x00,0x00,0x00,0x00,0x00,0x00}, // 11{0x00,0x00,0x00,0x00,0x00,0x00}, // 12{0x00,0x00,0x00,0x00,0x00,0x00}, // 13{0x00,0x00,0x00,0x00,0x00,0x00}, // 14{0x00,0x00,0x00,0x00,0x00,0x00}, // 15{0x00,0x00,0x00,0x00,0x00,0x00}, // 16{0x00,0x00,0x00,0x00,0x00,0x00}, // 17{0x00,0x00,0x00,0x00,0x00,0x00}, // 18{0x00,0x00,0x00,0x00,0x00,0x00}, // 19{0x00,0x00,0x00,0x00,0x00,0x00}, // 20{0x00,0x00,0x00,0x00,0x00,0x00}, // 21{0x00,0x00,0x00,0x00,0x00,0x00}, // 22{0x00,0x00,0x00,0x00,0x00,0x00}, // 23{0x00,0x00,0x00,0x00,0x00,0x00}, // 24{0x00,0x00,0x00,0x00,0x00,0x00}, // 25{0x00,0x00,0x00,0x00,0x00,0x00}, // 26{0x00,0x00,0x00,0x00,0x00,0x00}, // 27{0x00,0x00,0x00,0x00,0x00,0x00}, // 28{0x00,0x00,0x00,0x00,0x00,0x00}, // 29{0x00,0x00,0x00,0x00,0x00,0x00}, // 30{0x00,0x00,0x00,0x00,0x00,0x00}, // 31{0x00,0x00,0x00,0x00,0x00,0x00}, // sp 32{0x00,0x00,0x2f,0x00,0x00,0x00}, // ! 33{0x00,0x07,0x00,0x07,0x00,0x00}, // " 34{0x14,0x7f,0x14,0x7f,0x14,0x00}, // # 35{0x24,0x2a,0x7f,0x2a,0x12,0x00}, // $ 36{0x36,0x49,0x55,0x22,0x50,0x00}, // & 38 {0x00,0x05,0x03,0x00,0x00,0x00}, // ' 39 {0x00,0x1c,0x22,0x41,0x00,0x00}, // ( 40 {0x00,0x41,0x22,0x1c,0x00,0x00}, // ) 41 {0x14,0x08,0x3E,0x08,0x14,0x00}, // * 42 {0x08,0x08,0x3E,0x08,0x08,0x00}, // + 43 {0x00,0x00,0x50,0x30,0x00,0x00}, // , 44 {0x10,0x10,0x10,0x10,0x10,0x00}, // - 45 {0x00,0x60,0x60,0x00,0x00,0x00}, // . 46 {0x20,0x10,0x08,0x04,0x02,0x00}, // / 47 {0x3E,0x51,0x49,0x45,0x3E,0x00}, // 0 48 {0x00,0x42,0x7F,0x40,0x00,0x00}, // 1 49 {0x42,0x61,0x51,0x49,0x46,0x00}, // 2 50 {0x21,0x41,0x45,0x4B,0x31,0x00}, // 3 51 {0x18,0x14,0x12,0x7F,0x10,0x00}, // 4 52 {0x27,0x45,0x45,0x45,0x39,0x00}, // 5 53 {0x3C,0x4A,0x49,0x49,0x30,0x00}, // 6 54 {0x01,0x71,0x09,0x05,0x03,0x00}, // 7 55 {0x36,0x49,0x49,0x49,0x36,0x00}, // 8 56 {0x06,0x49,0x49,0x29,0x1E,0x00}, // 9 57 {0x00,0x36,0x36,0x00,0x00,0x00}, // : 58 {0x00,0x56,0x36,0x00,0x00,0x00}, // ; 59 {0x08,0x14,0x22,0x41,0x00,0x00}, // < 60 {0x14,0x14,0x14,0x14,0x14,0x00}, // = 61 {0x00,0x41,0x22,0x14,0x08,0x00}, // > 62 {0x02,0x01,0x51,0x09,0x06,0x00}, // ? 63 {0x32,0x49,0x59,0x51,0x3E,0x00}, // @ 64 {0x7E,0x11,0x11,0x11,0x7E,0x00}, // A 65 {0x7F,0x49,0x49,0x49,0x36,0x00}, // B 66 {0x3E,0x41,0x41,0x41,0x22,0x00}, // C 67 {0x7F,0x41,0x41,0x22,0x1C,0x00}, // D 68 {0x7F,0x49,0x49,0x49,0x41,0x00}, // E 69 {0x7F,0x09,0x09,0x09,0x01,0x00}, // F 70 {0x3E,0x41,0x49,0x49,0x7A,0x00}, // G 71 {0x7F,0x08,0x08,0x08,0x7F,0x00}, // H 72 {0x00,0x41,0x7F,0x41,0x00,0x00}, // I 73 {0x20,0x40,0x41,0x3F,0x01,0x00}, // J 74 {0x7F,0x08,0x14,0x22,0x41,0x00}, // K 75 {0x7F,0x40,0x40,0x40,0x40,0x00}, // L 76 {0x7F,0x02,0x0C,0x02,0x7F,0x00}, // M 77 {0x7F,0x04,0x08,0x10,0x7F,0x00}, // N 78 {0x3E,0x41,0x41,0x41,0x3E,0x00}, // O 79 {0x7F,0x09,0x09,0x09,0x06,0x00}, // P 80{0x7F,0x09,0x19,0x29,0x46,0x00}, // R 82{0x46,0x49,0x49,0x49,0x31,0x00}, // S 83{0x01,0x01,0x7F,0x01,0x01,0x00}, // T 84{0x3F,0x40,0x40,0x40,0x3F,0x00}, // U 85{0x1F,0x20,0x40,0x20,0x1F,0x00}, // V 86{0x3F,0x40,0x38,0x40,0x3F,0x00}, // W 87{0x63,0x14,0x08,0x14,0x63,0x00}, // X 88{0x07,0x08,0x70,0x08,0x07,0x00}, // Y 89{0x61,0x51,0x49,0x45,0x43,0x00}, // Z 90{0x00,0x7F,0x41,0x41,0x00,0x00}, // [ 91{0x55,0x2A,0x55,0x2A,0x55,0x00}, //55 92{0x00,0x41,0x41,0x7F,0x00,0x00}, // ] 93{0x04,0x02,0x01,0x02,0x04,0x00}, // ^ 94{0x40,0x40,0x40,0x40,0x40,0x00}, // _ 95{0x00,0x01,0x02,0x04,0x00,0x00}, // ' 96{0x20,0x54,0x54,0x54,0x78,0x00}, // a 97{0x7F,0x48,0x44,0x44,0x38,0x00}, // b 98{0x38,0x44,0x44,0x44,0x20,0x00}, // c 99{0x38,0x44,0x44,0x48,0x7F,0x00}, // d 100{0x38,0x54,0x54,0x54,0x18,0x00}, // e 101{0x08,0x7E,0x09,0x01,0x02,0x00}, // f 102{0x0C,0x52,0x52,0x52,0x3E,0x00}, // g 103{0x7F,0x08,0x04,0x04,0x78,0x00}, // h 104{0x00,0x44,0x7D,0x40,0x00,0x00}, // i 105{0x20,0x40,0x44,0x3D,0x00,0x00}, // j 106{0x7F,0x10,0x28,0x44,0x00,0x00}, // k 107{0x00,0x41,0x7F,0x40,0x00,0x00}, // l 108{0x7C,0x04,0x18,0x04,0x78,0x00}, // m 109{0x7C,0x08,0x04,0x04,0x78,0x00}, // n 110{0x38,0x44,0x44,0x44,0x38,0x00}, // o 111{0x7C,0x14,0x14,0x14,0x08,0x00}, // p 112{0x08,0x14,0x14,0x18,0x7C,0x00}, // q 113{0x7C,0x08,0x04,0x04,0x08,0x00}, // r 114{0x48,0x54,0x54,0x54,0x20,0x00}, // s 115{0x04,0x3F,0x44,0x40,0x20,0x00}, // t 116{0x3C,0x40,0x40,0x20,0x7C,0x00}, // u 117{0x1C,0x20,0x40,0x20,0x1C,0x00}, // v 118{0x3C,0x40,0x30,0x40,0x3C,0x00}, // w 119{0x44,0x28,0x10,0x28,0x44,0x00}, // x 120{0x0C,0x50,0x50,0x50,0x3C,0x00}, // y 121{0x44,0x64,0x54,0x4C,0x44,0x00}, // z 122{0xD5,0x01,0x80,0x01,0x80,0xAB}, // <50 123 {0xFF,0x81,0x81,0x81,0x81,0xFF}, //50<= <100 124{0xFF,0x81,0xBD,0xBD,0x81,0xFF}, //100<= <150 125{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, //>=150 126{0x00,0x00,0x00,0x00,0x00,0x00} // sp 127};/*******************显示一幅图****************/uchar dal11[]={//------------------------------------------------------------------------------/*--图像的数据*//*-- 图像宽度*高度=84x48 --*/0xE0,0xFE,0xFE,0xFE,0xFF,0xFF,0xFF,0xE7,0xFB,0xBB,0xBB,0x5B,0xE7,0xFF,0xFF,0xE7,0xFB,0xBB,0xBB,0x5B,0xE7,0xFF,0xFF,0xF7,0xF7,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0xF7,0xFB,0xFB,0xF7,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF3,0xFB,0xFB,0x03,0xFB,0xFB,0xF3,0xFF,0xFF,0x3F,0x5F,0x5F,0x5F,0x5F,0x3F,0xFF,0xFF,0x3F,0xDF,0xDF,0xDF,0x9F,0xFF,0xFF,0xFF,0xDF,0xDF,0x07,0xDF,0xDF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFE,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF9,0xF7,0xF7,0xF7,0xF7,0xF8,0xFF,0xFF,0xF9,0xF7,0xF7,0x37,0xF7,0xF8,0xFF,0xFF,0xF7,0xF7,0xF0,0xF7,0xF7,0x7F,0x7F,0x7F,0x7C,0x7B,0x77,0x77,0x7B,0x7C,0x7F,0x7F,0x3F,0x7F,0xFF,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x77,0xB0,0x77,0xFF,0xFF,0x3F,0xFF,0xF8,0xF7,0xF7,0xF7,0xF7,0xFB,0xFF,0xFF,0xF3,0xF6,0xF6,0x36,0xF9,0xFF,0xFF,0xFF,0xFF,0xFF,0xF8,0xF7,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x81,0xBD,0xBD,0xBD,0xBD,0x00,0xBD,0xBD,0xBD,0xBD,0x80, 0xFD,0xFF,0xFF,0xFF,0x00,0xFF,0xFD,0xED,0xED,0x01,0xED,0xCD,0xAD,0xFD,0xFF,0x00, 0xFF,0xFF,0xFF,0x00,0xDB,0xDB,0x00,0x7F,0x5B,0xDB,0xDA,0x03,0xDA,0xDB,0xDB,0xDB, 0xFF,0xF7,0x76,0xB6,0xC6,0xF6,0x36,0xF7,0xFB,0x7B,0x80,0xFB,0xFB,0x01,0xFB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0xFB,0xFA,0xFA,0xFA,0xFA,0xFA,0xFA,0xFA,0xFA,0xFA,0xF0,0xFF,0xDF,0x1D,0xFC,0xFE,0xFE,0xF0,0xFF,0xF7,0xFB,0xFC,0xFF,0xFE,0xFD,0xF3,0xFB,0xFF,0xFE,0xFC,0xFE,0xFE,0xFE,0xF6,0xFA,0xFD,0xFE,0xFF,0xFB, 0xF7,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE3,0xDD,0xBE,0xBE,0xBE,0xDD,0xFF,0xBE,0xBE,0x80,0xBD,0xBE,0xFE,0xFC,0xFF,0xFF,0xCD,0xB6,0xBA,0xBA,0x81,0xBF, 0xFF,0xFF,0x99,0xB6,0xB6,0xB6,0xCC,0xFF,0xFF,0xFF,0x80,0xBD,0xBE,0xBE,0xBE,0xC1, 0xFF,0xFE,0xFC,0xE2,0x1F,0xCF,0xF2,0xFC,0xFE,0xFF,0xE3,0xDD,0xBE,0xBE,0xDD,0xE3, 0xFF,0xFF,0xC1,0xBA,0xBA,0xBA,0xBA,0xD9,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x7F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x7F,0x0F,};void xp11()//写图函数{uchar e;uchar t;uchar k1;uint d;d=0;for(t=0;t<6;t++){for(k1=0;k1<84;k1++){setadd(k1,t);e=dal11[d];write_byte(e,1);d=d+1;}}}//主函数实现的功能是循环显示图片和擦除void main(void){/* put your own code here */DisableInterrupts;/******************SetClock*******************/CLKSEL=0X00; //disengage PLL to systemPLLCTL_PLLON=1; //turn on PLLSYNR =0xc0 | 0x07;REFDV=0xc0 | 0x01;POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=128MHz;_asm(nop); //BUS CLOCK=64M_asm(nop);while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;CLKSEL_PLLSEL =1; //engage PLL to system;while(FSTAT_CCIF == 0); //wait if command in progressFCLKDIV = 0x0F; //set prescaler//EnableInterrupts;for(;;){xp11();DelaymS(2000);qp();DelaymS(2000);_FEED_COP(); /* feeds the dog */} /* loop forever *//* please make sure that you never leave main */ }void Initlcd(void){//LCD端口初始化,GPIO输出DDRM_DDRM0=1;DDRM_DDRM1=1;DDRM_DDRM2=1;DDRP_DDRP4=1;DDRP_DDRP7=1;DelaymS(1);res=0;DelaymS(1);res=1;sce=0;DelaymS(1);sce=1;sdin=1;sclk=1;write_byte(0x21,0);//初始化LCD,write_byte(0xcc,0);//设置液晶偏执电压write_byte(0x20,0);//使用基本指令qp();//write_byte(0x0c,0); //设定显示模式,正常显示sce=0;}void write_byte(byte dd,byte a)//{char i;dc=a;for(i=0;i<8;i++){if(dd&mask_table[i]) {sdin=1;} else {sdin=0;}sclk=0;sclk=1;}dc=1;sce=1;sdin=1;}void setadd(byte a,byte d)//{write_byte((a|0x80),0); //Xwrite_byte((d|0x40),0); //Y}void qp(void)//{byte t;byte k;for(t=0;t<6;t++){for(k=0;k<84;k++){setadd(k,t);write_byte(0,1);}}}void DelaymS(word delay){word i, j;for ( i = delay; i != 0; i -- ){for ( j = 7000; j != 0; j -- ) ;for ( j = 6320; j != 0; j -- ) ;} }。
诺基亚5110液晶使用及显示程序实例
该模块具有以下特点:●84x48 的点阵LCD,可以显示4 行汉字,●采用串行接口与主处理器进行通信,接口信号线数量大幅度减少,包括电源和地在内的信号线仅有9 条。
支持多种串行通信协议(如AVR 单片机的SPI、MCS51 的串口模式0等),传输速率高达4Mbps,可全速写入显示数据,无等待时间。
●可通过导电胶连接模块与印制版,而不用连接电缆,用模块上的金属钩可将模块固定到印制板上,因而非常便于安装和更换。
●LCD 控制器/驱动器芯片已绑定到LCD 晶片上,模块的体积很小。
●采用低电压供电,正常显示时的工作电流在200μA 以下,且具有掉电模式。
LPH7366 的这些特点非常适合于电池供电的便携式通信设备和测试设备中C8051F学习笔记:Nokia 5110驱动Nokia5110是一款经典机型,可能由于经典的缘故,旧机器很多,所以很多电子工程师就把旧机器的屏幕拆下来,自己驱动Nokia5110,用于开发的设备显示,取代LCD1602。
使用Nokia5110液晶的四大理由1)性价比高,LCD1602可以显示32个字符,而Nokia5110可以显示15个汉字,30个字符。
Nokia5110裸屏仅8.8元,LCD1602一般15元左右,LCD 12864一般50~70元。
2)接口简单,仅四根I/O线即可驱动,LCD1602需11根I/O线,LCD12864需12根。
3)速度快,是LCD12864的20倍,是LCD1602的40倍。
4)Nokia5110工作电压3.3V,正常显示时工作电流200uA以下,具有掉电模式,适合电池供电的便携式移动设备。
可以在市场上买到Nokia5110的裸屏和带PCB的Nokia5110屏幕,因为N okia5110是不带背光的,所以通常商家会在PCB上按了几个背光LED,上电就能亮,建议大家还是买那种连上PCB的5110。
Nokia5110原理图:商家把该引出的管脚都引出了,下面就可以连接C8051F的相应管脚,写程序驱动5110了。
NOKIA_5110液晶51单片机驱动程序
#include <reg51.h>/* 雨亭电子代码测试环境:JME-2核心板+1T指令周期的STC单片机(51内核STC12LE5A60S2)+33M 晶振单片机工作电压3.3V程序默认IO连接方式:sce-P0^0; res-P0^1; dc-P0^2; sdin-P1^5; sclk-P1^7;*/sbit sce = P2^0; //片选sbit res = P2^1; //复位,0复位sbit dc = P2^2; //1写数据,0写指令sbit sdin = P2^3; //数据sbit sclk = P2^4; //时钟//6*16字符unsigned char code shuzi[]={/*-- 文字: > --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=6x16 --*/0x00,0x02,0x04,0x88,0x50,0x20,0x00,0x02,0x01,0x00,0x00,0x00,/*-- 文字: W --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=6x16 --*/0x1C,0xE0,0x3C,0xE0,0x1C,0x00,0x00,0x03,0x00,0x03,0x00,0x00,/*-- 文字: Y --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=6x16 --*/0x04,0x1C,0xE0,0x1C,0x04,0x00,0x00,0x02,0x03,0x02,0x00,0x00,/*-- 文字: G --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=6x16 --*/0xF0,0x08,0x04,0x44,0xCC,0x40,0x00,0x01,0x02,0x02,0x01,0x00};unsigned char code hanzi[]={/*-- 文字: 单--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x00,0x7C,0x55,0x56,0xFC,0x56,0x55,0x54,0x7C,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x07,0x01,0x01,0x01,0x01,0x01,0x00,/*-- 文字: 片--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x00,0xFF,0x48,0x48,0x48,0x4F,0xC8,0x08,0x08,0x08,0x00,0x04,0x02,0x01,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,/*-- 文字: 机--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x84,0x64,0xFF,0x24,0x44,0xFE,0x02,0x02,0xFF,0x02,0x00,0x00,0x01,0x00,0x07,0x04,0x02,0x01,0x00,0x00,0x07,0x04,0x07,0x00,/*-- 文字: 开--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x20,0x22,0x22,0xFE,0x22,0x22,0x22,0xFE,0x22,0x23,0x22,0x00,0x04,0x04,0x02,0x01,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,/*-- 文字: 发--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x08,0x0E,0x88,0x78,0x2F,0xE8,0x28,0xA9,0x6A,0x08,0x08,0x00,0x04,0x02,0x05,0x04,0x02,0x02,0x01,0x02,0x02,0x04,0x04,0x00,/*-- 文字: 工--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x03,0x02,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x04,0x04,0x00,/*-- 文字: 作--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x10,0x08,0xFC,0x13,0x08,0x04,0xFF,0x24,0x24,0x24,0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x01,0x01,0x01,0x01,0x00,/*-- 文字: 室--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x04,0x06,0x4A,0x6A,0x5A,0xCB,0x4A,0x5A,0x6A,0x4A,0x06,0x00,0x04,0x04,0x05,0x05,0x05,0x07,0x05,0x05,0x05,0x04,0x04,0x00,/*-- 文字: 雨--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x02,0xFA,0x9A,0x2A,0x0A,0xFE,0x9A,0x2A,0x0A,0xFB,0x02,0x00,0x00,0x07,0x00,0x01,0x00,0x07,0x00,0x05,0x04,0x07,0x00,0x00,/*-- 文字: 亭--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x60,0x22,0xA2,0xBA,0xAA,0xAB,0xAA,0xAA,0xBA,0x22,0x60,0x00,0x00,0x00,0x00,0x04, 0x04,0x07,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: 电--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0xFC,0x94,0x94,0x94,0xFF,0x94,0x94,0x94,0xFE,0x04,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x04,0x04,0x04,0x04,0x06,0x00,/*-- 文字: 子--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x20,0x21,0x21,0x21,0x21,0xF9,0x29,0x25,0x23,0x31,0x20,0x00,0x00,0x00,0x00,0x04,0x04,0x07,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: 第--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x04,0xEA,0xAB,0xAE,0xAA,0xFC,0xAA,0xAB,0xAE,0xBA,0x82,0x00,0x04,0x04,0x02,0x01, 0x00,0x07,0x00,0x02,0x02,0x02,0x01,0x00,/*-- 文字: 一--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: 行--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x48,0x24,0xF3,0x08,0x09,0x09,0x09,0x09,0xF9,0x09,0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x04,0x04,0x04,0x07,0x00,0x00,0x00,/*-- 文字: 二--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,/*-- 文字: 三--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x02,0x22,0x22,0x22,0x22,0x22,0x22,0x23,0x02,0x00,0x00,0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04,0x04,0x06,0x04,0x00};void delayms(unsigned int ii)//1ms延时函数{unsigned int i,x;for (x=0;x<ii;x++){for (i=0;i<100;i++);}}/*--------------------------------------------LCD_write_byte: 使用SPI接口写数据到LCD输入参数:dt:写入的数据;command :写数据/命令选择;编写日期:20080918----------------------------------------------*/void LCD_write_byte(unsigned char dt, unsigned char command){unsigned char i;sce=0;dc=command;for(i=0;i<8;i++){if(dt&0x80)sdin=1;elsesdin=0;dt=dt<<1;sclk=0;sclk=1;}dc=1;sce=1;sdin=1;}/*---------------------------------------LCD_init: 3310LCD初始化编写日期:20080918----------------------------------------- */void LCD_init(void){res=0;delayms(10);res=1;LCD_write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令LCD_write_byte(0xC6,0);//设定液晶偏置电压LCD_write_byte(0x06,0);//温度校正LCD_write_byte(0x13,0);;//1:48LCD_write_byte(0x20,0);//使用基本指令LCD_write_byte(0x0C,0);//设定显示模式,正常显示}/*-------------------------------------------LCD_set_XY: 设置LCD坐标函数输入参数:X:0-83 Y:0-5编写日期:20080918---------------------------------------------*/void LCD_set_XY(unsigned char X, unsigned char Y){LCD_write_byte(0x40 | Y, 0);// columnLCD_write_byte(0x80 | X, 0);// row}/*------------------------------------------LCD_clear: LCD清屏函数编写日期:20080918--------------------------------------------*/void LCD_clear(void){unsigned char t;unsigned char k;LCD_set_XY(0,0);for(t=0;t<6;t++){for(k=0;k<84;k++){LCD_write_byte(0x00,1);}}}/*---------------------------------------------LCD_write_shu: 显示6(宽)*16(高)点阵列数字字母符号等半角类输入参数:c:显示的字符;编写日期:20080918-----------------------------------------------*/void LCD_write_shu(unsigned char row, unsigned char page,unsigned char c) //row:列page:页dd:字符{unsigned char i;LCD_set_XY(row*6, page);// 列,页for(i=0; i<6;i++){LCD_write_byte(shuzi[c*12+i],1);}LCD_set_XY(row*6, page+1);// 列,页for(i=6; i<12;i++){LCD_write_byte(shuzi[c*12+i],1);}}/*---------------------------------------------LCD_write_hanzi: 显示12(宽)*16(高)点阵列汉字等半角类输入参数:c:显示的字符;编写日期:20080918-----------------------------------------------*/void LCD_write_hanzi(unsigned char row, unsigned char page,unsigned char c) //row:列page:页dd:字符{unsigned char i;LCD_set_XY(row*6, page);// 列,页for(i=0; i<12;i++){LCD_write_byte(hanzi[c*24+i],1);}LCD_set_XY(row*6, page+1);// 列,页for(i=12; i<24;i++){LCD_write_byte(hanzi[c*24+i],1);}}main(){unsigned char k;sce=0;res=0;for(k=0;k<250;k++);res=1;LCD_init(); //初始化LCD模块LCD_clear(); //清屏幕LCD_write_hanzi(0,0,0); //单LCD_write_hanzi(2,0,1); //片LCD_write_hanzi(4,0,2); //机LCD_write_hanzi(6,0,3); //开LCD_write_hanzi(8,0,4); //发LCD_write_hanzi(10,0,5); //工LCD_write_hanzi(12,0,6); //作LCD_write_hanzi(0,2,7); //室LCD_write_hanzi(2,4,8); //雨LCD_write_hanzi(4,4,9); //亭LCD_write_hanzi(6,4,10); //电LCD_write_hanzi(8,4,11); //子LCD_write_shu(10,4,0); //>LCD_write_shu(11,4,1); //WLCD_write_shu(12,4,2); //YLCD_write_shu(13,4,3); //Gwhile(1){delayms(5000);}。
nokia 5110 LCD显示4行汉字库函数
writeByte = font6x8[str][shiftCnt]>>2; lcd_write_byte(DATA, writeByte); shiftCnt++; } } }
} if(line_temp[y] == 3 ) { Lcd_third_line_save[x_Axis] = cnCharStr[number].cnData[shiftCnt +
} shiftCnt++; } nexthalf = 12; shiftCnt = 0; }
作 */
if(line_temp[y] == 2 || line_temp[y] == 5) /* 处理 2、4 行的情况,需特殊处理 */ {
Lcd_First_line_save[xAxis] = font6x8[str][shiftCnt]; } if(line_temp[y] == 3 ) {
Lcd_third_line_save[xAxis] = font6x8[str][shiftCnt]; } shiftCnt++; } shiftCnt = 0; }
for(x_Axis = x; x_Axis < x+12; x_Axis++) /* 上半区字节下移 4 位 | 上行字符或操
{ lcd_set_xy(x_Axis,line_temp[y] - 1);
if(line_temp[y] == 2 ) {
诺基亚5110LCD驱动程序
/******************************************************************** NOKIA5110(3310)液晶屏驱动程序** 晶振频率:11.0592M** 线路->单片机实验开发板A******************************************************************/#include/*-- -------定义Nokia5110 引角---- -----*/sbit sclk = P3^3;sbit sdin = P3^4;sbit dc = P3^5;sbit sce = P3^7;sbit res = P3^6;void initNokia5110(void); /* NOkia 5110 初始化*/void clearNokia5110(void); /* 清除屏幕整屏清空*/void Display_char(unsigned char x,unsigned char y,char *s); /* 写字符x 设置显示字符的X位置; y 设置显示字符的Y 位置*s 显示字符的首地址*/void Display_num(unsigned char x,unsigned char y,char s); /* 写数字x 设置显示字符的X位置; y 设置显示字符的Y 位置s 显示数字*/void write_byte(unsigned char data1); /* 发送1字节到NOkia 5110 */void setxy(unsigned char x,unsigned char y); /* 设置显示坐标x 行坐标(0-83) unsigned char y 列坐标(0-5) */void delay(unsigned int time);void main(void){initNokia5110(); /* NOkia 5110 初始化*/clearNokia5110(); /* 清除屏幕整屏清空*/Display_char(1,2,""); /* 写字符x 设置显示字符的X位置; y 设置显示字符的Y位置*s 显示字符的首地址*/Display_char(10,4,"NOKIA5510"); /* 写字符x 设置显示字符的X位置; y 设置显示字符的Y位置*s 显示字符的首地址*///Display_num(0,0,9); // 写数字while(1);}/****************************5110 0-9字模**************************//*函数原型:无/*函数功能:0-9字模/*输入参数:无/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/ unsigned char code asc2tab[][6] ={{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },// sp{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 },// !{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 },// "{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 },// #{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 },// ${ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 },// %{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 },// &{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 },// '{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 },// ({ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 },// ){ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 },// *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 },// +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 },// ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 },// -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 },// .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 },// /{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E },// 0{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 },// 1{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 },// 2{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 },// 3 { 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 },// 4 { 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 },// 5 { 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 },// 6 { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 },// 7 { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 },// 8 { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E },// 9 { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 },// : { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 },// ; { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 },// < { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 },// = { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 },// > { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 },// ? { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E },// @ { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C },// A { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 },// B { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 },// C { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C },// D { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 },// E { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 },// F { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A },// G { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F },// H{ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 },// I { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 },// J { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 },// K { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 },// L { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F },// M { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F },// N { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E },// O { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 },// P { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E },// Q { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 },// R { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 },// S { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 },// T { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F },// U { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F },// V { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F },// W { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 },// X { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 },// Y { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 },// Z { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 },// [ { 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 },// 55 { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 },// ] { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 },// ^{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 },// _ { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 },// ' { 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 },// a { 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 },// b { 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 },// c { 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F },// d { 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 },// e { 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 },// f { 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C },// g { 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 },// h { 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 },// i { 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 },// j { 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 },// k { 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 },// l { 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 },// m { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 },// n { 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 },// o { 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 },// p { 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC },// q { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 },// r { 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 },// s { 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 },// t{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C },// u{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C },// v{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C },// w{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 },// x{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C },// y{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 },// z{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 }};/****************************Nokia5110初始化函数**************************//*函数原型:initNokia5110(void)/*函数功能:Nokia5110初始化/*输入参数:无/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/void initNokia5110(void){delay(10); //系统复位res = 0;delay(2);res = 1;dc = 0;write_byte(0x21); //;芯片是活动的(PD=0) 使用扩展指令集write_byte(0xd5);write_byte(0x20); //;芯片是活动的(PD=0) 使用水平寻址(V=0) 使用基本指令集(H=0) write_byte(0x0c); //;设置显示配置(D=1 E=0)}/****************************Nokia5110清屏函数*********************//*函数原型:void clearNokia5110(void)/*函数功能:Nokia5110清屏/*输入参数:无/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/void clearNokia5110(void){unsigned int i,j;for(i=0;i<6;i++){setxy(j,i);dc = 1;while (j<84){write_byte(0x00);j++;}j = 0;}}/*--------------------------------------;模块名称:Display_char(unsigned char x,unsigned char y,char *s);;功能:写字符;占用资源:;参数说明:x 设置显示字符的X位置; y 设置显示字符的Y位置*s 显示字符的首地址;创建日期:2001.01.19;版本:VER 2.0 ★STALI☆;-------------------------------------*/void Display_char(unsigned char x,unsigned char y,char *s){unsigned char line;setxy(x,y);while(*s){for(line=0;line<6;line++){dc = 1;write_byte(asc2tab[*s - 32][line]);}}sce = 1;}/****************************Nokia5110写数字函数*********************/ /*函数原型:void Display_num(unsigned char x,unsigned char y,char s)/*函数功能:Nokia5110写数字/*输入参数:x 设置显示字符的X位置; y 设置显示字符的Y位置s 显示数字/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/ void Display_num(unsigned char x,unsigned char y,char s){unsigned char line;setxy(x,y);dc = 1;for(line=0;line<6;line++){write_byte(asc2tab[s+16][line]);}sce = 1;}/*************************Nokia5110发送1字节函数*********************/ /*函数原型:void Display_num(unsigned char x,unsigned char y,char s)/*函数功能:发送1字节到NOkia 5110/*输入参数:x 设置显示字符的X位置; y 设置显示字符的Y位置s 显示数字/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/ void write_byte(unsigned char data1){unsigned char i;res = 1;sce = 0;for(i=0;i<8;i++){sdin = (bit) (data1&0x80);;sclk = 1;data1 <<=1;}}/*************************Nokia5110设置显示坐标函数*********************/ /*函数原型:void setxy(unsigned char x,unsigned char y)/*函数功能:设置显示坐标/*输入参数:unsigned char x 行坐标(0-83) unsigned char y 列坐标(0-5)/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/ void setxy(unsigned char x,unsigned char y){dc = 0;write_byte(y|0x40); //设置y轴。
诺基亚5110液晶显示汉字程序
诺基亚5110液晶显示汉字程序默认分类 2009-11-03 21:19 阅读31 评论0字号:大中小包含三个文件,主函数,液晶驱动函数和字符串头文件,用STC单片机在5110液晶上显示“好好学习吧”五个汉字。
提取字模用"Pctolcd2002完美版"软件,字模选项中的设置为列行式+逆向+每行显示16*8+C51格式,可随意更改文字内容。
液晶文件lcd.csbit RST_5110=P1^4; //low activesbit CE_5110=P1^3; //low activesbit DC_5110=P1^2; //0=command,1=datasbit SDI_5110=P1^1; //rise edge enablesbit SCK_5110=P1^0; //clock#define DATA 1#define CMD 0unsigned char code asc2[][6] ={{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // sp{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, // !{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, // "{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, // #{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, // ${ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 }, // %{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, // &{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, // '{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, // ({ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, // ){ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, // *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, // +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, // ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, // -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, // .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, // /{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7 { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8 { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E }, // 9 { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 }, // : { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 }, // ; { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 }, // < { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 }, // = { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 }, // > { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, // ? { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, // @ { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, // A { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, // C { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, // D { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, // E { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, // F { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, // G { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, // H { 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, // I { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, // J { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, // K { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, // L { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, // M { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, // N { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, // O { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, // P { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, // Q { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, // R { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, // S { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, // T { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, // U { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, // V { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, // W { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, // X { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, // Z { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, // [ { 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 }, // 55 { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, // ] { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, // ^ { 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, // _ { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, // '{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, // b{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, // c{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, // d{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, // f{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, // g{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, // h{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, // i{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, // j{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, // k{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, // l{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, // m{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, // n{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, // o{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, // p{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, // q{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, // r{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, // s{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, // t{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, // u{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, // v{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, // w{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, // x{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, // y{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, // z{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 } // horiz lines};unsigned char code hanzi[][16]={{0x10,0x10,0xF0,0x1F,0x10,0xF0,0x80,0x82,0x82,0x82,0xF2,0x8A,0x86,0x82,0x80,0x00},{0x80,0x43,0x22,0x14,0x0C,0x73,0x20,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00},/*"好",0*/ {0x10,0x10,0xF0,0x1F,0x10,0xF0,0x80,0x82,0x82,0x82,0xF2,0x8A,0x86,0x82,0x80,0x00},{0x80,0x43,0x22,0x14,0x0C,0x73,0x20,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00},/*"好",1*/ {0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00}, {0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00},/*"学",2*/ {0x00,0x00,0x02,0x02,0x0A,0x12,0x22,0x62,0x02,0x82,0x82,0x42,0x02,0xFE,0x00,0x00},{0x00,0x00,0x04,0x0C,0x04,0x02,0x02,0x01,0x01,0x00,0x20,0x40,0x80,0x7F,0x00,0x00},/*"习",3*/{0xFE,0x02,0x02,0x02,0xFE,0x00,0xFE,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0xFE,0x00}, {0x07,0x01,0x01,0x01,0x03,0x00,0x3F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x70,0x00},/*"吧",0*/};void Delay_us(uchar t)//延时{while(--t);}void Write_Byte_5110(uchar Data ,bit CMD_DATA){uchar i;CE_5110=0; //Enable LCDDC_5110=CMD_DATA;//写命令还是写数据for(i=0;i<8;i++){SCK_5110=0;if(Data & 0x80) //MSB first高位优先SDI_5110=1;//传输1elseSDI_5110=0;//传输0SCK_5110=1;//始终为1时锁存Data<<=1;}SCK_5110=0;//时钟清零CE_5110=1; //disable LCD关液晶使能}void Clear_5110(void){uint i;Write_Byte_5110(0x80,CMD);//写地址for(i=0;i<504;i++){Write_Byte_5110(0x00,DATA);//set the addr as 0x00}}void Set_R_C_5110(uchar R,uchar C) //R=0~5;C=0~83{if(R<=5 && C<=83){Write_Byte_5110(0x40|R,CMD);//写行地址Write_Byte_5110(0x80|C,CMD);//写列地址}}void Init_5110(void){Delay_us(1); //reset LCDRST_5110=0;//复位清零Delay_us(1);RST_5110=1;Write_Byte_5110(0x21,CMD); //扩展指令Write_Byte_5110(0xc8,CMD); //设置偏压Write_Byte_5110(0x20,CMD); //标准指令Clear_5110();Write_Byte_5110(0x0c,CMD); //标准显示模式}void Write_Char_5110(uchar Char){uchar i,j;i=Char-0x20;for(j=0;j<6;j++){Write_Byte_5110(asc2[i][j],DATA);}}void Write_String_5110(uchar *P){uchar i;for(i=0;i<strlen(P);i++){Write_Char_5110(P[i]);}}void Write_hanzis_5110(){uchar i,j;for(i=0;i<10;i=i+2){for(j=0;j<16;j++){Write_Byte_5110(hanzi[i][j],DATA);}}}void Write_hanzix_5110(){uchar i,j;for(i=1;i<10;i=i+2)for(j=0;j<16;j++){Write_Byte_5110(hanzi[i][j],DATA);}}}主函数main.c#include <reg51.h>#include <string.h>#define uchar unsigned char#define uint unsigned int#include"lcd.c"uchar flag,flag1;unsigned char buff[14]="0123456789abcd";unsigned char buff1[14]="---------";void delay(unsigned int z){unsigned int x;unsigned char y;for(x=z;x>0;x--)for(y=20;y>0;y--);}void main(void){delay(500);Init_5110(); //初始化LCD// Write_Byte_5110(0x0c,CMD); //标准显示模式 Set_R_C_5110(1,4);Write_String_5110(buff1);Set_R_C_5110(0,0);Write_String_5110(buff);Set_R_C_5110(2,0);Write_String_5110(buff);// Write_Byte_5110(0x0d,CMD); //反显Set_R_C_5110(3,0);Write_hanzis_5110();Set_R_C_5110(4,0);Write_hanzix_5110();while(1);。
AVR驱动Nokia3310(5V驱动3v)
发布:2009-6-02 16:33 | 作者:tiankai | 来源:本站 | 查看:672次 | 字号: 小 中 大 动手学AVR单片机二十七、Nokia3310/5110液晶显示实验 一、电路实现 本实例的电路图如下:
二、Nokia3310/5110液晶介绍 Nokia3310/5110液晶的驱动控制器为PCD8544,它可以驱动
//数字75的的ASCII字符是英文字
母大写K
Delayms(1000);
}
}
//us级别的延时函数
void Delayus(unsigned int lus)
{
while(lus--)
{
_delay_loop_2(3);
//_delay_loop_2(1)是延时4个时钟周
期,参数为3则延时12
//个时钟周期,本实验用12M晶体,则12个时钟周期为
0x7F, 0x04, 0x08, 0x10, 0x7F, // N 0x3E, 0x41, 0x41, 0x41, 0x3E, // O 0x7F, 0x09, 0x09, 0x09, 0x06, // P 0x3E, 0x41, 0x51, 0x21, 0x5E, // Q 0x7F, 0x09, 0x19, 0x29, 0x46, // R 0x46, 0x49, 0x49, 0x49, 0x31, // S 0x01, 0x01, 0x7F, 0x01, 0x01, // T 0x3F, 0x40, 0x40, 0x40, 0x3F, // U 0x1F, 0x20, 0x40, 0x20, 0x1F, // V 0x3F, 0x40, 0x38, 0x40, 0x3F, // W 0x63, 0x14, 0x08, 0x14, 0x63, // X 0x07, 0x08, 0x70, 0x08, 0x07, // Y 0x61, 0x51, 0x49, 0x45, 0x43, // Z 0x00, 0x7F, 0x41, 0x41, 0x00, // [ 0x55, 0x2A, 0x55, 0x2A, 0x55, // 55 0x00, 0x41, 0x41, 0x7F, 0x00, // ] 0x04, 0x02, 0x01, 0x02, 0x04, // ^ 0x40, 0x40, 0x40, 0x40, 0x40, // _ 0x00, 0x01, 0x02, 0x04, 0x00, // ’ 0x20, 0x54, 0x54, 0x54, 0x78, // a 0x7F, 0x48, 0x44, 0x44, 0x38, // b 0x38, 0x44, 0x44, 0x44, 0x20, // c 0x38, 0x44, 0x44, 0x48, 0x7F, // d 0x38, 0x54, 0x54, 0x54, 0x18, // e 0x08, 0x7E, 0x09, 0x01, 0x02, // f 0x18, 0xA4, 0xA4, 0xA4, 0x7C, // g 0x7F, 0x08, 0x04, 0x04, 0x78, // h
5110LCD小板原理图
5110LCD小板原理图:不妥的地方请指出1.增加了74HC165,在不增加任何I/O口的情况下提供8个按键2.板载LCD阻容复位,LCD_reset可以外部控制也可以阻容复位3.背光可以控制4.最少4个I/O端口就可以控制液晶和读取8个按键不放心,按照上图接线进行实物测试结果通过,程序如下:$Device= m16 使用mega16$Stack = 32 堆栈32字节$Clock = 4 时钟4MHz$ShiftOut Data=PORTB.5 ,Clk=PORTB.7,Msb 申明一个简易SPI口$GLCD Nokia3310, SCLK=PORTB.7, SDIN=PORTB.5, DC=PORTB.1, SCE=PORTB.4 3310液晶连接定义$Def RES=PORTB.0 复位脚$LeadChar=" ", Format(3,0) 显示数据格式化$Def SL = PORTB.1 去74HC165锁存$Def led = PORTB.3 去3310背光控制Dim n_key As Byte 保存按键键值Dim n As Byte 显示一个变量n好观察3310有没有运行Dim F0HD As Flash Byte 英文字库F0HDn_key=255Set DDRB.0: Nop 3: Set RES 复位3310LCDSet DDRB.3Reset led 点亮3310背光灯GLcdInit 初始化3310LCDFontSet F0HD 选择字体GLcd(0,5),"" 显示一个字符串DoGLcd(0,2),"key=";n_key 显示键值GLcd(60, 0), n 显示一个变量n好观察3310有没有运行Incr nReset SLSet SL 锁存74HC165Reset DDRB.5 将SDIN变为输入为读取74HC165做准备Set DDRB.7n_key=ShiftIn 获得键值n_key=Not n_keyWaitMs 100Set DDRB.5 将SDIN变为输出为写3310LCD做准备Loop$Include "C:\FastAVR\Nokia3310\F0HD.bas"图片附件:该帖子在2006-1-7 0:26:48 编辑过本站有售:30元/片Nokia 3310手机的点阵LCD模块不仅小巧、省电、驱动容易,而且价钱也便宜。
NOKIA5110参考程序
//说明:以下函数在STM32F405RGT6上验证过,应用于其他条件下根据自身需要做移植//nokia5110.h//********************* nokia5110.h *********************////串行线协议,并非I2c总线协议,可达4MHz//84*48 14*6个6*8字符左上角为(0,0) 纵向六个字节,可水平会垂直寻址//高位在下面,先写入高位工作电压2.7V~3.3V 六根线控制背光线可省//********************* nokia5110.h *********************//#include "stm32f4xx.h"//*****************调试函数启用****************////#define Nokia5110_debug 1#ifdef Nokia5110_debugvoid Nokia5110_dbg(void);#endif//*********************IO引脚定义*********************//Nokia5110: PC0-RST CS-PC1 DC-PC2 Din-PC3 PA0-CLK PA1-BL//注:!!要对IO进行设置,设置在其他文件中,为包含在本WORD文档中//液晶背光控制#define lcd_lbg_1 G PIOA->BSRRL=GPIO_Pin_1 //背光高电平亮#define lcd_lbg_0 G PIOA->BSRRH=GPIO_Pin_1 //背光低电平灭#define lcd_rst_1 GPIOC->BSRRL=GPIO_Pin_0 //复位,0复位#define lcd_ce_1 GPIOC->BSRRL=GPIO_Pin_1 //片选端口#define lcd_dc_1 GPIOC->BSRRL=GPIO_Pin_2 //数据1/指令0#define lcd_da_1 GPIOC->BSRRL=GPIO_Pin_3 //数据#define lcd_clk_1 GPIOA->BSRRL=GPIO_Pin_0 //时钟(4Mhz)#define lcd_rst_0 GPIOC->BSRRH=GPIO_Pin_0 //复位,0复位#define lcd_ce_0 GPIOC->BSRRH=GPIO_Pin_1 //片选端口#define lcd_dc_0 GPIOC->BSRRH=GPIO_Pin_2 //数据1/指令0#define lcd_da_0 GPIOC->BSRRH=GPIO_Pin_3 //数据#define lcd_clk_0 GPIOA->BSRRH=GPIO_Pin_0 //时钟(4Mhz)//*********************IO引脚定义*********************//*********************nokia5110命令定义*********************#define kongbai 0x08 //显示空白#define zhengchang 0x0c //显示正常#define quanxian 0x09 //全部显示#define fanzhuan 0x0d //显示反转#define pd_h_kz 0x80;//显示空白//*********************nokia5110命令定义*********************//***********************字库定义声明************************//6 x 8ascii码,0x10--0x1f可以自定义externconst u8 font6x8[128][6];//8*16 数字字母字小写asc码-0x57externconst u8 font8x16[36][16];//0_哈//1_尔//2_滨//3_工//4_程//5_大//6_学//7_图//8_书//9_馆externconst u8 hanzi[10][32];//数据水平字节垂直,40*40qq图片externconst u8 Image_QQ[200];//*********************字库定义声明************************//***********************函数声明**************************//写入的数据voidlcdwrdat(u8 dat);//连续写入的数据,*s为字符数组或字符串ascii码voidlcdwrcom(u8 com);void lcdclear(void);//清屏//lcd反清屏函数voidlcdall(void);//5110lcd初始化函数上电100ms内完成voidlcd_init(void);//**0<=x<=83,0<=y<=47,设置坐标voidlcd_set_xy(u8 x,u8 y);//**0<=x<=13,0<=y<=5,写一个字符dat为asc码voidlcddispone(u8 x,u8 y,u8 dat);//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组,num为数据长度voidlcddispmore(u8 x,u8 y,u8 num,u8 *s);//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组voidlcddispstr(u8 x,u8 y,u8 *s);//**0<=x<=9,0<=y<=5,写8x16数字或小写字母voidlcd_write_shu(u8 x, u8 y,u8 dat);//**0<=x<=9,0<=y<=5,写16x16汉字index为汉字编号如0_哈voidlcd_write_hanzi(u8 x, u8 y,u8 index);//**0<=x<=83,0<=y<=5,显示图片,width为宽度,hight为高度自动除8 如40*40 voidlcddispimage(u8 x,u8 y,u8 *s,u8 width,u8 hight);//显示10位数占用11位voiddisp_long(u8 x,u8 y,longdat);//有符号数显示,占6位void disp_s16(u8 x,u8 y,s16 dat);//8位无符号数显示,占3位void disp_u8(u8 x,u8 y,u8 dat);//8位数HEX码显示,占2位voiddisp_hex(u8 x,u8 y,u8 dat);//16位数HEX码显示,占4位void disp_hex2(u8 x,u8 y,u16 dat);//32位数HEX码显示,占8位void disp_hex4(u8 x,u8 y,u32 dat);//***********************函数声明**************************/*函数调用示例lcd_lbg_1; //开背光lcd_init(); //初始化lcd模块lcdclear(); //清屏幕for(i=0;i<2;i++)for(j=0;j<5;j++)lcd_write_hanzi(j,i,j*5+i);lcddispmore(0,4,6,"shgued");lcddispmore(0,5,6,"shgued");lcddispone(6,4,0x30);lcddispone(7,4,'1');lcddispone(6,5,0x32);lcddispone(7,5,'3');lcd_write_shu(6,5,'4');lcd_write_shu(9,5,'9');delay(2000);lcdclear(); //清屏幕lcddispimage(10,1,(u8*)Image_QQ,40,40);//??u8**///Nokia5110.c//********************* Nokia5110.c *********************////串行线协议,并非I2c总线协议,可达4MHz(实际上上可以比这快,自己验证下,改变下面系统频率)//84*48 14*6个6*8字符左上角为(0,0) 纵向六个字节,可水平会垂直寻址//高位在下面,先写入高位工作电压2.7V~3.3V 六根线控制背光线可省//********************* Nokia5110.c *********************//#include "stm32f4xx.h"#include "Nokia5110.h"#define lcd_adress_check 1 //地址范围检验功能启用//Nokia5110延时,系统频率定义!!根据需要设置//#define cpuclk_84Mhz//#define cpuclk_72Mhz//#define cpuclk_144Mhz//#define cpuclk_168Mhz//#define cpuclk_48Mhz//#define cpuclk_24Mhz#define cpuclk_16Mhz//72Mhz 1 6*(n+1)个nop//#define delay_4Mhz for(lcd_cnt=0;lcd_cnt<3;lcd_cnt++)//0.125us//72Mhz 9clk 4Mhz *2#ifdef cpuclk_84Mhz#define delay_4Mhz __asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop")#elifdefined cpuclk_72Mhz#define delay_4Mhz __asm("nop;nop;nop;nop;nop;nop;nop;nop;nop")#elifdefined cpuclk_144Mhz#define delay_4Mhz__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop");__asm("nop;nop;nop;nop;nop;nop;nop;n op;nop")#elifdefined cpuclk_168Mhz#define delay_4Mhz__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop");__asm("nop;nop;nop;nop;nop;n op;nop;nop;nop;nop;nop");__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop")#elifdefined cpuclk_48Mhz#define delay_4Mhz __asm("nop;nop;nop;nop;nop;nop")#elifdefined cpuclk_24Mhz#define delay_4Mhz __asm("nop;nop;nop")#elifdefined cpuclk_16Mhz#define delay_4Mhz __asm("nop;nop")#else#define delay_4Mhz __asm("nop")#endif//6 x 8ascii码,0x10--0x1f可以自定义//右上5*7 字节倒序高位在下const u8 font6x8[128][6] ={{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, //0x00// 0 ??{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, //0x01// 1{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, //0x02// 2{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, //0x03// 3{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, //0x04// 4{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 }, //0x05// 5{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, //0x06// 6{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, //0x07// 7{ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, //0x08// 8{ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, //0x0a// *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, //0x0b// +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, //0x0c// ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, //0x0d// -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, //0x0e// .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, //0x0f// /{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //0x10// sp{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, //0x11// !{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, //0x12// "{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, //0x13// #{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, //0x14// ${ 0x00, 0x23, 0x13, 0x08, 0x64, 0x62 }, //0x15// % ?{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, //0x16// &{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, //0x17// '{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, //0x18// ({ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, //0x19// ){ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, //0x1a// *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, //0x1b// +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, //0x1c// ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, //0x1d// -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, //0x1e// .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, //0x1f// / ??{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //0x20// sp{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, //0x21// !{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, //0x22// "{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, //0x23// #{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, //0x24// ${ 0x00, 0x23, 0x13, 0x08, 0x64, 0x62 }, //0x25// %{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, //0x26// & { 0x00, 0x04, 0x08, 0x10, 0x20, 0x40 }, //0x27// \ 换行{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, //0x28// ({ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, //0x29// ){ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, //0x2a// *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, //0x2b// +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, //0x2c// ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, //0x2d// -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, //0x2e// .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, //0x2f// /{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, //0x30// 0{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, //0x31// 1{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, //0x32// 2{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, //0x33// 3{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, //0x34// 4{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, //0x36// 6 { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, //0x37// 7 { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, //0x38// 8 { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E }, //0x39// 9 { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 }, //0x3a// : { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 }, //0x3b// ; { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 }, //0x3c// < { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 }, //0x3d// = { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 }, //0x3e// > { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, //0x3f// ? { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, //0x40// @ { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, //0x41// A { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, //0x42// B { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, //0x43// C { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, //0x44// D { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, //0x45// E { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, //0x46// F { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, //0x47// G { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, //0x48// H { 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, //0x49// I { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, //0x4a// J { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, //0x4b// K { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, //0x4c// L { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, //0x4d// M { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, //0x4e// N { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, //0x4f// O { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, //0x50// P { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, //0x51// Q { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, //0x52// R { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, //0x53// S { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, //0x54// T { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, //0x55// U { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, //0x56// V { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, //0x57// W { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, //0x58// X { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, //0x59// Y { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, //0x5a// Z { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, //0x5b// [ { 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 }, //0x5c// \\? { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, //0x5d// ] { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, //0x5e// ^ { 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, //0x5f// _ { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, //0x60// '{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, //0x62// b{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, //0x63// c{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, //0x64// d{ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 }, //0x65// e{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, //0x66// f{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, //0x67// g{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, //0x68// h{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, //0x69// i{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, //0x6a// j{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, //0x6b// k{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, //0x6c// l{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, //0x6d// m{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, //0x6e// n{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, //0x6f// o{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, //0x70// p{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, //0x71// q{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, //0x72// r{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, //0x73// s{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, //0x74// t{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, //0x75// u{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, //0x76// v{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, //0x77// w{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, //0x78// x{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, //0x79// y{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, //0x7a// z{ 0x00, 0x18, 0x7E, 0x81, 0x00, 0x00 }, //0x7b// {{ 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00 }, //0x7c// |{ 0x00, 0x00, 0x81, 0x7E, 0x18, 0x00 }, //0x7d// }{ 0x00, 0x04, 0x08, 0x04, 0x02, 0x04 }, //0x7e// ~{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 } //0x7f// horiz lines};//8*16 数字字母字母小写asc码-0x57const u8 font8x16[36][16]={/*-- 文字: 0 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00},/*-- 文字: 1 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00}, /*-- 文字: 2 --*/{0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},/*-- 文字: 3 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: 4 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00},/*-- 文字: 5 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: 6 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: 7 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00},/*-- 文字: 8 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00},/*-- 文字: 9 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00},/*-- 文字: a --10*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20},/*-- 文字: b --11*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: c --12*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00}, /*-- 文字: d --13*/{0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20},/*-- 文字: e --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00},/*-- 文字: f --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},/*-- 文字: g --16*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00},/*-- 文字: h --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20},/*-- 文字: i --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},/*-- 文字: j --19*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00},/*-- 文字: k --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00},/*-- 文字: l --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},/*-- 文字: m --22*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F},/*-- 文字: n --23*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20}, /*-- 文字: o --24*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00},/*-- 文字: p --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: q --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80},/*-- 文字: r --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00},/*-- 文字: s --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00},/*-- 文字: t --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00},/*-- 文字: u --30*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20},/*-- 文字: v --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00},/*-- 文字: w --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00},/*-- 文字: x --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00},/*-- 文字: y --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00}, /*-- 文字: z --35*/{0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00} };//******************************************//0_哈//1_尔//2_滨//3_工//4_程//5_大//6_学//7_图//8_书//9_馆//******************************************const u8 hanzi[10][32]={/*-- 文字: 哈--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x00,0xFC,0x04,0x04,0xFC,0x20,0x50,0x48,0x44,0x43,0x44,0x48,0x50,0x20,0x20,0x00, 0x00,0x0F,0x04,0x04,0x0F,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00},/*-- 文字: 尔--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x80,0x40,0x20,0x18,0x0F,0x08,0x08,0xE8,0x08,0x08,0x08,0x08,0x28,0x18,0x00,0x00, 0x20,0x10,0x08,0x06,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x02,0x04,0x08,0x30,0x00},/*-- 文字: 滨--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x10,0x60,0x02,0x0C,0xD0,0x0C,0xE4,0x24,0x25,0x26,0x24,0x14,0x04,0x14,0x0C,0x00, 0x04,0x04,0x7C,0x03,0x08,0x88,0x4F,0x29,0x09,0x09,0x09,0x2F,0x49,0x89,0x08,0x00},/*-- 文字: 工--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00},/*-- 文字: 程--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0x3E,0x22,0x22,0x22,0x22,0x22,0x3E,0x00,0x00, 0x08,0x06,0x01,0xFF,0x01,0x06,0x40,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x41,0x00},/*-- 文字: 大--*///5/*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00},/*-- 文字: 学--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00},/*-- 文字: 图--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x00,0xFE,0x02,0x42,0x22,0x32,0x5E,0x92,0x52,0x32,0x12,0x02,0x02,0xFE,0x00,0x00,0x00,0xFF,0x42,0x42,0x42,0x51,0x55,0x64,0x69,0x41,0x42,0x42,0x42,0xFF,0x00,0x00},/*-- 文字: 书--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x00,0x00,0x08,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0xF9,0x02,0x04,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0x01,0x01,0x01,0x21,0x41,0x21,0x1F,0x00,0x00},/*-- 文字: 馆--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x40,0x30,0x8F,0x28,0x18,0x10,0x0C,0xE4,0x24,0x25,0x26,0x24,0xE4,0x14,0x0C,0x00,0x00,0x00,0x7F,0x20,0x10,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0xF8,0x00,0x00}};//数据水平字节垂直,40*40qq图片const u8 Image_QQ[200] = {0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XC0,0XE0,0XF0,0XF8,0XE8,0XF4,0XF4,0X7E,0X7E,0X7E,0XFF,0XFF,0XFE,0XFE,0X7E,0X7E,0XFC,0XFC,0XF8,0XF0,0XF0,0XC0,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X10,0X70,0XF0,0XF8,0XF0,0XE0,0XC0,0X80,0XFC,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X7F,0X61,0X61,0X60,0X60,0X7F,0X7F,0X73,0X67,0X43,0X40,0XE0,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0XC0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X03,0X07,0X0F,0X1F,0XFF,0XFF,0X7F,0X7F,0XFF,0XFF,0XEC,0XFE,0XDC,0XDC,0XD8,0XB8,0XB8,0XB8,0XB8,0XF8,0XF8,0XF8,0XFC,0XFE,0XFE,0XFD,0XFF,0XFF,0XFF,0X7F,0XFF,0XFF,0XFF,0XF0,0XE0,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X3F,0X7F,0XC0,0X00,0X00,0X00,0X01,0X01,0X01,0X01,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X3F,0X7F,0X7F,0X7F,0X7F,0X3F,0X00,0X80,0XE0,0XFF,0X3F,0X1F,0X3F,0X7F,0X7E,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X38,0X44,0X41,0X83,0X86,0X8C,0X88,0X90,0XB0,0XA0,0XE0,0X60,0X60,0X20,0X20,0X20,0X60,0X60,0XE0,0XB0,0XB0,0X98,0X98,0X8C,0X86,0X87,0X41,0X48,0X30,0X00,0X00,0X00,0X00};/* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*//* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*///*//写入的数据voidlcdwrdat(u8 dat){u8i;lcd_clk_1;lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出for(i=0;i<8;i++)//先位7{if(dat&0x80)lcd_da_1;//正边沿取样elselcd_da_0;dat=dat<<1;lcd_clk_0;delay_4Mhz;lcd_clk_1;delay_4Mhz;}lcd_ce_1;delay_4Mhz;}//连续写入的数据,*s为字符数组或字符串ascii码voidlcdwrdat_cont(u8 *s,u8 num){u8i,j,dat;lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出lcd_clk_1;for(j=0;j<num;j++){dat=*s;for(i=0;i<8;i++)//先位7{if(dat&0x80)lcd_da_1;//正边沿取样elselcd_da_0;dat=dat<<1;lcd_clk_0;delay_4Mhz;lcd_clk_1;delay_4Mhz;}s++;}lcd_ce_1;delay_4Mhz;}//写入指令voidlcdwrcom(u8 com){u8i;lcd_clk_1;lcd_ce_0;lcd_dc_0;for(i=0;i<8;i++){if(com&0x80)lcd_da_1;elselcd_da_0;com=com<<1;lcd_clk_0;delay_4Mhz;lcd_clk_1;delay_4Mhz;}lcd_ce_1;delay_4Mhz;}//5110lcd初始化函数上电100ms内完成voidlcd_init(void){unsignedinti;lcd_ce_0;//<30ms内lcd_rst_0;//delay(1);//>100nsfor(i=0;i<100000;i++);//没明显效果lcd_rst_1;lcdwrcom(0x21);//lcd功能设置:芯片活动,水平寻址,使用扩展指令lcdwrcom(4+0x10);//1:48//对于有些NOKIA5110,VOP值设置不对显示不出东西,有一个函数用来调试选出合适的值lcdwrcom(54+0x80);//设置VOP值,没有明显效果,0<vop<90//Vlcd=3.06+(VOP)*0.06,本例VOP为0B0101 0000为十进制的80,Vlcd=7.86Vlcdwrcom(0x20);//lcd功能设置:芯片活动,水平寻址,使用基本指令lcdwrcom(0x0C);//设定显示配置:普通模式}//**0<=x<=83,0<=y<=47,设置坐标voidlcd_set_xy(u8 x, u8 y){lcdwrcom(0x40 | y);lcdwrcom(0x80 | x);}//lcd清屏函数voidlcdclear(void){u8t,k,i;lcd_set_xy(0,0);lcd_clk_1;lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出lcd_da_0;for(t=0;t<6;t++){for(k=0;k<84;k++){//lcdwrdat(0x00);for(i=0;i<8;i++)//先位7{lcd_clk_1;delay_4Mhz;lcd_clk_0;delay_4Mhz;}}}lcd_ce_1;delay_4Mhz;}//lcd反清屏函数voidlcdall(void){u8t,k,i;lcd_set_xy(0,0);lcd_clk_1;lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出lcd_da_1;for(t=0;t<6;t++){for(k=0;k<84;k++){//lcdwrdat(0x00);for(i=0;i<8;i++)//先位7{lcd_clk_1;delay_4Mhz;lcd_clk_0;delay_4Mhz;}}}lcd_ce_1;delay_4Mhz;}//**0<=x<=13,0<=y<=5,写一个字符dat为asc码voidlcddispone(u8 x,u8 y,u8 dat){u8i;#ifdeflcd_adress_checkif(x>13) x=13;if(y>5) y=5;#endiflcdwrcom(0x40 | y);// columnlcdwrcom(0x80 | x*6);// rowfor (i=0; i<6; i++)lcdwrdat(font6x8[dat][i]);}//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组,num为数据长度voidlcddispmore(u8 x,u8 y,u8 num,u8 *s){u8i,j;#ifdeflcd_adress_checkif(x>13) x=13;if(y>5) y=5;#endiflcdwrcom(0x40 | y);// columnlcdwrcom(0x80 | x*6);// rowfor(j=0;j<num;j++){for (i=0; i<6; i++)lcdwrdat(font6x8[*s][i]);s++;if(*s=='\0')break;}}//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组voidlcddispstr(u8 x,u8 y,u8 *s){#ifdeflcd_adress_checkif(x>13) x=13;if(y>5) y=5;#endiflcdwrcom(0x40 | y);// columnlcdwrcom(0x80 | x*6);// rowwhile(*s!='\0'){lcdwrdat_cont((u8*)font6x8[*s],6);s++;}}//**0<=x<=9,0<=y<=5,写8x16数字或小写字母voidlcd_write_shu(u8 x, u8 y,u8 dat){u8i;#ifdeflcd_adress_checkif(x>9) x=9;if(y>2) y=2;#endifx=x<<3;y=y<<1;lcd_set_xy(x, y);// 列,页for(i=0; i<8;i++){lcdwrdat(font8x16[dat][i]);}lcd_set_xy(x, y+1);// 列,页for(i=8; i<16;i++){lcdwrdat(font8x16[dat][i]);}}//**0<=x<=9,0<=y<=5,写16x16汉字index为汉字编号如0_哈void lcd_write_hanzi(u8 x, u8 y,u8 index) //row:列page:页dd:字符{u8i;#ifdeflcd_adress_checkif(x>4) x=4;if(y>2) y=2;#endifx=x<<4;y=y<<1;lcd_set_xy(x, y);// 列,页for(i=0; i<16;i++){lcdwrdat(hanzi[index][i]);}lcd_set_xy(x, y+1);// 列,页for(i=16; i<32;i++){lcdwrdat(hanzi[index][i]);}}//**0<=x<=83,0<=y<=5,显示图片,width为宽度,hight为高度自动除8 如40*40 voidlcddispimage(u8 x,u8 y,u8 *s,u8 width,u8 hight){u8i,j,k,wid,hig,dat;hight=hight/8;if((x+width)>84)wid=84-x;elsewid=width;if((y+hight)>6)hig=6-y;elsehig=hight;for(j=0;j<hig;j++){lcdwrcom(0x40 | y+j);lcdwrcom(0x80 | x);lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出lcd_clk_1;for(i=0;i<wid;i++)//先位7{dat=*s;for(k=0;k<8;k++){if(dat&0x80)lcd_da_1;//正边沿取样elselcd_da_0;dat<<=1;lcd_clk_0;delay_4Mhz;lcd_clk_1;delay_4Mhz;}s++;}s=s-wid+width;}lcd_ce_1;delay_4Mhz;}//*//显示10位数占用11位voiddisp_long(u8 x,u8 y,longdat){u8disp[12];if(dat>=0) disp[0]=' ';else{disp[0]='-';dat=-dat;}disp[1]=dat/1000000000+48;disp[2]=dat/100000000%10+48;disp[3]=dat/10000000%10+48;disp[4]=dat/1000000%10+48;disp[5]=dat/100000%10+48;disp[6]=dat/10000%10+48;disp[7]=dat/1000%10+48;disp[8]=dat/100%10+48;disp[9]=dat/10%10+48;disp[10]=dat%10+48;disp[11]='\0';if(disp[1]=='0'){disp[1]=disp[0];disp[0]=' ';if(disp[2]=='0'){disp[2]=disp[1];disp[1]=' ';if(disp[3]=='0'){disp[3]=disp[2];disp[2]=' ';if(disp[4]=='0'){disp[4]=disp[3];disp[3]=' ';if(disp[5]=='0'){disp[5]=disp[4];disp[4]=' ';if(disp[6]=='0'){disp[6]=disp[5];disp[5]=' ';if(disp[7]=='0'){disp[7]=disp[6];disp[6]=' ';if(disp[8]=='0'){disp[8]=disp[7];disp[7]=' ';if(disp[8]=='0'){disp[9]=disp[8];disp[8]=' ';}}}}}}}}}lcddispmore(x,y,11,disp);}//16位有符号数显示,占6位void disp_s16(u8 x,u8 y,s16 dat){u8disp[6];if(dat<0){disp[0]='-';dat=-dat;}else{disp[0]=' ';}disp[1]=dat/10000+0x30;disp[2]=dat/1000%10+0x30;disp[3]=dat/100%10+0x30;disp[4]=dat/10%10+0x30;disp[5]=dat%10+0x30;if(disp[1]==0x30){disp[1]=disp[0];disp[0]=' ';if(disp[2]==0x30){disp[2]=disp[1];disp[1]=' ';if(disp[3]==0x30){disp[3]=disp[2];disp[2]=' ';if(disp[4]==0x30){disp[4]=disp[3];disp[3]=' ';。
(整理)诺基亚LCD5110液晶接线图和程序
该模块具有以下特点:●84x48 的点阵LCD,可以显示4 行汉字,●采用串行接口与主处理器进行通信,接口信号线数量大幅度减少,包括电源和地在内的信号线仅有9 条。
支持多种串行通信协议(如AVR 单片机的SPI、MCS51 的串口模式0等),传输速率高达4Mbps,可全速写入显示数据,无等待时间。
●可通过导电胶连接模块与印制版,而不用连接电缆,用模块上的金属钩可将模块固定到印制板上,因而非常便于安装和更换。
●LCD 控制器/驱动器芯片已绑定到LCD 晶片上,模块的体积很小。
●采用低电压供电,正常显示时的工作电流在200μA 以下,且具有掉电模式。
LPH7366 的这些特点非常适合于电池供电的便携式通信设备和测试设备中C8051F学习笔记:Nokia 5110驱动Nokia5110是一款经典机型,可能由于经典的缘故,旧机器很多,所以很多电子工程师就把旧机器的屏幕拆下来,自己驱动Nokia5110,用于开发的设备显示,取代LCD1602。
使用Nokia5110液晶的四大理由1)性价比高,LCD1602可以显示32个字符,而Nokia5110可以显示15个汉字,30个字符。
Nokia5110裸屏仅8.8元,LCD1602一般15元左右,LCD12864一般50~70元。
2)接口简单,仅四根I/O线即可驱动,LCD1602需11根I/O线,LCD12864需12根。
3)速度快,是LCD12864的20倍,是LCD1602的40倍。
4)Nokia5110工作电压3.3V,正常显示时工作电流200uA以下,具有掉电模式,适合电池供电的便携式移动设备。
可以在市场上买到Nokia5110的裸屏和带PCB的Nokia5110屏幕,因为Nokia5110是不带背光的,所以通常商家会在PCB上按了几个背光LED,上电就能亮,建议大家还是买那种连上PCB的51 10。
Nokia5110原理图:商家把该引出的管脚都引出了,下面就可以连接C8051F的相应管脚,写程序驱动5110了。
Nokia3310 5110液晶显示(使用说明+C程序)
3.3V的稳压管Nokia5110液晶屏完全新手学习笔记(一)3人收藏此文章, 我要收藏发表于1年前 , 已有3442次阅读共1个评论小Jay已经很久没有接触嵌入式了,这些天在学习51,还故意买了块Nokia 5110液晶屏来玩玩(因为便宜吧,嘻嘻~)。
一开始,小Jay不才,看5110芯片资料一头雾水,囧!不过呢,小Jay还是很努力的,经过几番研究,终于有些眉目,其实5110也并不难的。
此文提供给和我一样的鸟哥参考,希望能帮得上忙。
(*^__^*) 嘻嘻声明:1、本文章用于自己的知识回顾和提供给有需要的初学者,高手请飘过~2、本文章的内容均从“诺基亚5110液晶屏资料驱动芯片PCD8544中文数据手册.pdf”中,结合自己的理解,整理并简化出来的知识,更多详细内容请查看芯片手册。
另外,内容有不对的地方,望指正。
现在我们一步一步来:一、硬件链接:首先,看一下硬件(仅供参考,读者已对自己的硬件很熟悉,可以直接跳过。
):说明:图1:排针从左至右1到8位。
图2: 5110接口在板子中的区域。
图3: 8位排针对应连接5110液晶屏相应的引脚。
图4: 5110液晶显示屏对应8位排针JP19的插入方向。
再看一下我的板子的原理图:图5中,显示了8位排针JP19(即5110液晶屏的引脚)其中的5根与51单片机(本人的为STC89C516RD+)的PB I/O口的连接方式:5110_RST <---> PB2(P1.2)5110_SCE <---> PB3(P1.3)MOSI(sdin) <---> PB5(P1.5)MISO(dc) <---> PB6(P1.6)SCK <---> PB7(P1.7)这样,我们知道了用51单片机中的I/O口和5110引脚的链接方式。
二、引脚接线图请根据程序里的定义连接,51的程序默认接线为:看了这些默认接线,可能有个疑问:“这些位变量(引脚)究竟有什么用呢?”,带着这个疑问,请看5110芯片手册中的引脚说明(重点看红色区域):从这个引脚说明中,我们知道了不同的引脚,对应的功能。
诺基亚3310液晶显示模块资料及的应用
诺基亚3310液晶显示模块资料及的应用Nokia 3310手机的点阵LCD模块不仅小巧、省电、驱动容易,而且价钱也便宜。
因此,最近网上常见到不少朋友都在用单片机来驱动该模块,制做出很多作品。
实验目标在LCD上显示和移动汉字;在LCD上显示英文字符串;在LCD上显示位图。
实验电路图及工作原理由于3310LCD的工作电压范围是2.7-3.3V,因此实验中使用一个3.3V的稳压二极管D1将5V电源稳压为3.3V左右,为MCU和LCD供电。
MCU和LCD之间使用SPI接口传输数据。
LCD模块的引脚排列:从模块的背面看,管脚排列顺序从左至右分别为1至8脚。
如下图所示:∙注意:∙LCD模块的引脚即使用导线直接焊接上,也要用东西将金属引脚压下去,否则还是不能接触到内部电路实验源程序主程序:文件名是3310LCDTest.c#include <iom48v.h>#include <macros.h>#include "lcd.h"#include "bmp.h"/*******************************************/void main(void){OSCCAL=0x99;// 8M系统内部时钟校准//设置MCU的I/O口DDRB |= LCD_RST | LCD_DC | LCD_CE | SPI_MOSI | SPI_CLK| 0X02;SPSR |= BIT(SPI2X);// 设置SPI时钟倍速SPCR |= BIT(SPE)|BIT(MSTR);// 使能SPI接口,主机模式,4M时钟LCD_init(); //初始化LCD模块LCD_write_String(1,5,""); //显示英文字符串”“LCD_draw_map(0,2,AVR_bmp,40,24); //显示“AVR”位图LCD_draw_map(44,3,china_bmp,36,15); //显示”实验室“位图PORTB |= 0x02; //LED亮while(1){LCD_move_chi(0, 0, 25); //汉字移动显示}}LCD3310驱动程序:文件名3310LCD.c#include <iom48v.h>#include <macros.h>#include "lcd.h"#include "6x8.h"#include "chinese.h"/*---------------------------------------LCD_init: 3310LCD初始化编写日期:2004-8-10最后修改日期:2004-8-10----------------------------*/void LCD_init(void){PORTB &= ~LCD_RST;// 产生一个让LCD复位的低电平脉冲delay_1us();PORTB |= LCD_RST;PORTB &= ~LCD_CE ;// 关闭LCDdelay_1us();PORTB |= LCD_CE;// 使能LCDdelay_1us();LCD_write_byte(0x21, 0);// 使用扩展命令设置LCD模式LCD_write_byte(0xc8, 0);// 设置偏置电压LCD_write_byte(0x06, 0);// 温度校正LCD_write_byte(0x13, 0);// 1:48LCD_write_byte(0x20, 0);// 使用基本命令LCD_clear();// 清屏LCD_write_byte(0x0c, 0);// 设定显示模式,正常显示PORTB &= ~LCD_CE ;// 关闭LCD}/*----------------------------------------------------------------------- LCD_clear: LCD清屏函数编写日期:2004-8-10最后修改日期:2004-8-10-----------------------------------------------------------------------*/ void LCD_clear(void){unsigned int i;LCD_write_byte(0x0c, 0);LCD_write_byte(0x80, 0);for (i=0; i<504; i++)LCD_write_byte(0, 1);}/*----------------------------------------------------------------------- LCD_set_XY: 设置LCD坐标函数输入参数:X:0-83Y:0-5编写日期:2004-8-10最后修改日期:2004-8-10-----------------------------------------------------------------------*/ void LCD_set_XY(unsigned char X, unsigned char Y){LCD_write_byte(0x40 | Y, 0);// columnLCD_write_byte(0x80 | X, 0);// row}/*----------------------------------------------------------------------- LCD_write_char: 显示英文字符输入参数:c:显示的字符;编写日期:2004-8-10最后修改日期:2004-8-10-----------------------------------------------------------------------*/ void LCD_write_char(unsigned char c){unsigned char line;c -= 32;for (line=0; line<6; line++)LCD_write_byte(font6x8[c][line], 1);}/*----------------------------------------------------------------------- LCD_write_char: 英文字符串显示函数输入参数:*s:英文字符串指针;X、Y: 显示字符串的位置-----------------------------------------------------------------------*/void LCD_write_String(unsigned char X,unsigned char Y,char *s){LCD_set_XY(X,Y);while (*s){LCD_write_char(*s);s++;}}/*----------------------------------------------------------------------- LCD_write_chi: 在LCD上显示汉字输入参数:X、Y:显示汉字的起始X、Y坐标;ch_with :汉字点阵的宽度num:显示汉字的个数;line:汉字点阵数组中的起始行数row:汉字显示的行间距编写日期:2004-8-11最后修改日期:2004-8-12-----------------------------------------------------------------------*/ void LCD_write_chi(unsigned char X, unsigned char Y,unsigned char ch_with,unsigned char num,unsigned char line,unsigned char row){unsigned char i,n;LCD_set_XY(X,Y);//设置初始位置for (i=0;i<num;){for (n=0; n<ch_with*2; n++)//写一个汉字{if (n==ch_with)//写汉字的下半部分{if (i==0) LCD_set_XY(X,Y+1);elseLCD_set_XY((X+(ch_with+row)*i),Y+1);}LCD_write_byte(china_char[line+i][n],1);}i++;LCD_set_XY((X+(ch_with+row)*i),Y);}}/*----------------------------------------------------------------------- LCD_write_chi: 汉字移动输入参数:X、Y:显示汉字的起始X、Y坐标;T:移动速度;编写日期:2004-8-13最后修改日期:2004-8-13-----------------------------------------------------------------------*/void LCD_move_chi(unsigned char X, unsigned char Y, unsigned char T) {unsigned char i,n,j=0;unsigned char buffer_h[84]={0};unsigned char buffer_l[84]={0};for (i=0; i<156; i++){buffer_h[83] = china_char[i/12][j];buffer_l[83] = china_char[i/12][j+12];j++;if (j==12) j=0;for (n=0; n<83; n++){buffer_h[n]=buffer_h[n+1];buffer_l[n]=buffer_l[n+1];}LCD_set_XY(X,Y);for (n=0; n<83; n++){LCD_write_byte(buffer_h[n],1);}LCD_set_XY(X,Y+1);for (n=0; n<83; n++){LCD_write_byte(buffer_l[n],1);}delay_nms(T);}}/*----------------------------------------------------------------------- LCD_draw_map: 位图绘制函数输入参数:X、Y:位图绘制的起始X、Y坐标;*map:位图点阵数据;Pix_x:位图像素(长)Pix_y:位图像素(宽)编写日期:2004-8-13最后修改日期:2004-8-13-----------------------------------------------------------------------*/ void LCD_draw_map(unsigned char X,unsigned char Y,unsigned char *map, unsigned char Pix_x,unsigned char Pix_y){unsigned int i,n;unsigned char row;if (Pix_y%8==0) row=Pix_y/8;//计算位图所占行数elserow=Pix_y/8+1;for (n=0;n<row;n++){LCD_set_XY(X,Y);for(i=0; i<Pix_x; i++){LCD_write_byte(map[i+n*Pix_x], 1);}Y++;//换行}}/*----------------------------------------------------------------------- LCD_write_byte: 使用SPI接口写数据到LCD输入参数:data:写入的数据;command :写数据/命令选择;编写日期:2004-8-10最后修改日期:2004-8-13-----------------------------------------------------------------------*/ void LCD_write_byte(unsigned char data, unsigned char command){PORTB &= ~LCD_CE ;// 使能LCDif (command == 0)PORTB &= ~LCD_DC ;// 传送命令elsePORTB |= LCD_DC ;// 传送数据SPDR = data;// 传送数据到SPI寄存器while ((SPSR & 0x80) == 0);// 等待数据传送完毕PORTB |= LCD_CE ;// 关闭LCD}o延时程序:文件名delay.c/*----------------------------------------------------------------------- 延时函数系统时钟:8M-----------------------------------------------------------------------*/ void delay_1us(void)//1us延时函数{asm("nop");}void delay_nus(unsigned int n)//N us延时函数{unsigned int i=0;for (i=0;i<n;i++)delay_1us();}void delay_1ms(void)//1ms延时函数{unsigned int i;for (i=0;i<1140;i++);}void delay_nms(unsigned int n)//N ms延时函数{unsigned int i=0;for (i=0;i<n;i++)delay_1ms();}o lcd.h头文件//Mega48/8port B pinout for LCD.#define LCD_DC0x01//PB0#define LCD_CE0x04//PB2#define SPI_MOSI0x08//PB3#define LCD_RST0x10//PB4#define SPI_CLK0x20//PB5void LCD_init(void);void LCD_clear(void);void LCD_write_String(unsigned char X,unsigned char Y,char *s);void LCD_write_chi(unsigned char X, unsigned char Y,unsigned char ch_with,unsigned char num,unsigned char line,unsigned char row);void LCD_move_chi(unsigned char X, unsigned char Y, unsigned char T); void LCD_write_char(unsigned char c);void LCD_draw_map(unsigned char X,unsigned char Y,unsigned char *map, unsigned char Pix_x,unsigned char Pix_y);void LCD_write_byte(unsigned char data, unsigned char dc);void delay_1us(void);void delay_nus(unsigned int n);void delay_1ms(void);void delay_nms(unsigned int n);o点阵数据文件chinese.h文件:/*------------------------------------------------------------------------------ ;源文件 / 文字 : 欢迎光临电子爱好者俱乐部!;宽×高(像素): 12×13;字模格式/大小 : 单色点阵液晶字模,纵向取模,字节倒序/24字节;数据转换日期: 2004-8-12 14:22:30------------------------------------------------------------------------------*/ const unsigned char china_char[][24]={{0x14,0x24,0xC4,0x3C,0x04,0x30,0x0E,0xE8,0x08,0x28,0x18,0x00,0x04,0x03,0x00,0x09,0x0A,0x04,0x03,0x00,0x03,0x04,0x08,0x00},//汉字“欢”{0x10,0xF2,0x04,0x00,0xFC,0x84,0x82,0xFC,0x04,0x04,0xFC,0x00,0x0C,0x03,0x04,0x04,0x09,0x08,0x08,0x0B,0x08,0x09,0x09,0x00},//汉字“迎”{0x20,0x24,0x28,0xF0,0x20,0x3E,0xE0,0x30,0x28,0x24,0x20,0x00,0x08,0x08,0x04,0x03,0x00,0x00,0x07,0x08,0x08,0x08,0x0E,0x00},//汉字“光”0xF8,0x00,0xFE,0x00,0x20,0x98,0x8E,0x98,0xA8,0x88,0x88,0x00,0x03,0x00, 0x0F,0x00,0x00,0x0F,0x04,0x07,0x04,0x04,0x0F,0x00},//汉字“临”{0x00,0xF8,0x28,0x28,0x28,0xFE,0x28,0x28,0x28,0xFC,0x08,0x00,0x00,0x03, 0x01,0x01,0x01,0x07,0x09,0x09,0x09,0x09,0x0C,0x00},//汉字“电”{0x40,0x42,0x42,0x42,0x42,0xF2,0x52,0x4A,0x46,0x62,0x40,0x00,0x00,0x00, 0x00,0x08,0x08,0x0F,0x00,0x00,0x00,0x00,0x00,0x00},//汉字“子”{0x30,0x54,0x54,0x5C,0xF4,0x5C,0x52,0x5A,0x56,0x52,0x30,0x00,0x08,0x08, 0x04,0x0A,0x0B,0x05,0x05,0x0B,0x09,0x08,0x08,0x00},//汉字“爱”{0x88,0x78,0x0E,0x88,0x78,0x42,0x42,0xF2,0x4A,0x46,0x40,0x00,0x09,0x05, 0x02,0x03,0x04,0x00,0x08,0x0F,0x00,0x00,0x00,0x00},//汉字“好”{0x20,0x24,0x24,0xA4,0xFE,0xA4,0xB4,0xAC,0xA4,0x32,0x20,0x00,0x02,0x02, 0x01,0x0F,0x0A,0x0A,0x0A,0x0A,0x0F,0x00,0x00,0x00},//汉字“者”0x20,0xF8,0x06,0x00,0xFE,0x52,0x52,0x52,0x52,0xFE,0x00,0x00,0x00,0x0F, 0x01,0x09,0x05,0x03,0x01,0x01,0x03,0x05,0x09,0x00},//汉字“俱”{0x00,0x60,0x5C,0xC4,0x44,0x44,0xFA,0xC2,0x42,0x60,0x40,0x00,0x04,0x02, 0x01,0x00,0x08,0x08,0x0F,0x00,0x01,0x02,0x04,0x00},//汉字“乐”{0x24,0xAC,0xB4,0xA6,0xB4,0xAC,0x24,0xFC,0x04,0x74,0x8C,0x00,0x00,0x0F, 0x04,0x04,0x04,0x0F,0x00,0x0F,0x02,0x04,0x03,0x00},//汉字“部”{0x00,0x38,0xFC,0xFC,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//汉字“!”};6x8.h文件:// 6 x 8 font// 1 pixel space at left and bottom// index = ASCII - 32const unsigned char font6x8[][6] ={{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 },// ! { 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 },// " { 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 },// # { 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 },// $ { 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 },// % { 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 },// & { 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 },// ' { 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 },// ( { 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 },// ) { 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 },// * { 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 },// + { 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 },// , { 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 },// - { 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 },// . { 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 },// / { 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E },// 0 { 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 },// 1 { 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 },// 2 { 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 },// 3 { 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 },// 4 { 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 },// 5 { 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 },// 6 { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 },// 7{ 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E },// 9 { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 },// : { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 },// ; { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 },// < { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 },// = { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 },// > { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 },// ? { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E },// @ { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C },// A { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 },// B { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 },// C { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C },// D { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 },// E { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 },// F { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A },// G { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F },// H { 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 },// I { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 },// J { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 },// K { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 },// L { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F },// M { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F },// N { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E },// O{ 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E },// Q { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 },// R { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 },// S { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 },// T { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F },// U { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F },// V { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F },// W { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 },// X { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 },// Y { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 },// Z { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 },// [ { 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 },// 55 { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 },// ] { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 },// ^ { 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 },// _ { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 },// ' { 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 },// a { 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 },// b { 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 },// c { 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F },// d { 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 },// e { 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 },// f { 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C },// g{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 },// i{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 },// j{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 },// k{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 },// l{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 },// m{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 },// n{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 },// o{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 },// p{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC },// q{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 },// r{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 },// s{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 },// t{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C },// u{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C },// v{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C },// w{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 },// x{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C },// y{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 },// z{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 }// horiz lines};bmp.h文件/*------------------------------------------------------------------------------ ;源文件 / 文字 : AVR;宽×高(像素): 40×24;字模格式/大小 : 单色点阵液晶字模,纵向取模,字节倒序/120字节;数据转换日期: 2004-8-13------------------------------------------------------------------------------*/ unsigned char AVR_bmp[]={0x00,0x00,0x00,0x80,0xF0,0xF0,0x70,0xF0,0xF0,0x80,0x00,0x00,0x00,0x30,0xF0,0xF0,0xC0,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xF0,0x30,0x00,0xF0,0xF0,0xF0,0x70,0x70,0x70,0x70,0x70,0xF0,0xE0,0xC0,0x00,0x00,0x00,0xC0,0xF8,0xFF,0xFF,0xE3,0xE0,0xE3,0xFF,0xFF,0xFC,0xC0,0x00,0x00,0x01,0x0F,0x7F,0xFE,0xF0,0x80,0xF0,0xFE,0x7F,0x0F,0x01,0x00,0x00,0xFF,0xFF,0xFF,0x1C,0x1C,0x3C,0x7C,0xFC,0xEF,0xCF,0x07,0x00,0x00,0x06,0x07,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x07,0x06,0x00,0x00,0x00,0x00,0x03,0x07,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x01,0x07,0x07,0x07,0x04,0x00};/*------------------------------------------------------------------------------ ;源文件 / 文字 : 实验室;宽×高(像素): 36×15;字模格式/大小 : 单色点阵液晶字模,纵向取模,字节倒序/72字节;数据转换日期: 2004-8-13------------------------------------------------------------------------------*/ unsigned char china_bmp[]={0x20,0x18,0x88,0x28,0x48,0x0C,0xE8,0x08,0x08,0x28,0x18,0x00,0x84,0xF4, 0x84,0xFC,0x40,0x20,0x50,0x4C,0x50,0x20,0x40,0x00,0x10,0x18,0x28,0xA8, 0x68,0x2C,0x28,0x68,0xA8,0x28,0x18,0x00,0x02,0x12,0x12,0x13,0x0A,0x06, 0x03,0x06,0x0A,0x12,0x02,0x00,0x04,0x14,0x12,0x0F,0x10,0x17,0x10,0x17, 0x18,0x17,0x10,0x00,0x10,0x10,0x15,0x15,0x15,0x1F,0x15,0x15,0x15,0x11, 0x10,0x00}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
3.3V的稳压管
Nokia5110液晶屏完全新手学习笔记(一)
3人收藏此文章, 我要收藏发表于1年前 , 已有3442次阅读共1个评论
小Jay已经很久没有接触嵌入式了,这些天在学习51,还故意买了块Nokia 5110液晶屏来玩玩(因为便宜吧,嘻嘻~)。
一开始,小Jay不才,看5110芯片资料一头雾水,囧!不过呢,小Jay还是很努力的,经过几番研究,终于有些眉目,其实5110也并不难的。
此文提供给和我一样的鸟哥参考,希望能帮得上忙。
(*^__^*) 嘻嘻
声明:
1、本文章用于自己的知识回顾和提供给有需要的初学者,高手请飘过~
2、本文章的内容均从“诺基亚5110液晶屏资料驱动芯片PCD8544中文数据手册.pdf”中,结合自己的理解,整理并简化出来的知识,更多详细内容请查看芯片手册。
另外,内容有不对的地方,望指正。
现在我们一步一步来:
一、硬件链接:
首先,看一下硬件(仅供参考,读者已对自己的硬件很熟悉,可以直接跳过。
):
说明:
图1:排针从左至右1到8位。
图2: 5110接口在板子中的区域。
图3: 8位排针对应连接5110液晶屏相应的引脚。
图4: 5110液晶显示屏对应8位排针JP19的插入方向。
再看一下我的板子的原理图:
图5中,显示了8位排针JP19(即5110液晶屏的引脚)其中的5根与51单片机(本人的为STC89C516RD+)的PB I/O口的连接方式:
5110_RST <---> PB2(P1.2)
5110_SCE <---> PB3(P1.3)
MOSI(sdin) <---> PB5(P1.5)
MISO(dc) <---> PB6(P1.6)
SCK <---> PB7(P1.7)
这样,我们知道了用51单片机中的I/O口和5110引脚的链接方式。
二、引脚
接线图请根据程序里的定义连接,51的程序默认接线为:
看了这些默认接线,可能有个疑问:“这些位变量(引脚)究竟有什么用呢?”,带着这个疑问,请看5110芯片手册中的引脚说明
(重点看红色区域):
从这个引脚说明中,我们知道了不同的引脚,对应的功能。
那么,如何使用这些引脚来控制5110工作呢?
三、指令
5110液晶显示屏(PCD8544芯片),是通过发送指令和写入数据RAM来控制和显示数据的。
指令格式分为两种模式:
1、如果D/C(模式选择)置为低(为0),即位变量 dc = 0,为发送指令模式,那么接下来发送的8位字节解释为命令字节。
2、如果D/C置为高,即dc = 1; 为写入数据RAM模式,接下来的字节将存储到显示数据RAM。
注意:
1、每一个数据字节存入之后,地址计数自动递增。
在数据字节最后一位期间会读取D/C信号的电平。
2、每一条指令可用任意次序发送到PCD8544。
首先传送的是字节的MSB(高位)。
指令集:
结合表1和表2, 指令集不难读懂。
现在以红色横线所标识的指令来举例说明:
第一条(红色横线1),功能设置指令:
首先,D/C为0, 表示现在是指令模式,然后从表2看:
若要“使用基本指令集”,则PD = 0, V = 0, H = 0,那么相应地DB7~DB0分别为 00100000b,即0x20。
也就是说,发送0x20就能设置液晶“使用基本指令集”。
同理,使用“使用扩展指令集”,指令值为0x21。
第二条(红色横线2),显示控制:
显示模式有4种,分别是:显示空白,普通模式,开所有显示段,反转映象模式。
这些模式分别使用D and E来组合控制。
这样,我们控制显示为“普通模式”, 那么D要为1,E要为0, 这时DB7~DB0分别为 0000 1100b,即指令值为0x0C。
第三条(红色横线3),写入数据指令:
写入数据,首先D/C必须为1,表示现在是写入数据RAM模式,
DB7~DB0就是相应的数据值。
到这里,我们知道了5110液晶屏是使用这样的指令集来控制和显示数据的。
那么,我们如何把指令值写进去呢?
一篇发不完,请看笔记二。
四、时序图
没错,要向液晶屏写入数据,我们需要通过模拟一个串行总线协议来写入数据。
先来看看传送一个字节(指令)的时序图:
如果能看懂时这些序图的兄弟,就不要听我废话啦。
请飘过~~
从时序图1看出:
1. SCE片选为0时开始发送数据。
2. 时钟信号SCLK仅在SCE片选为0时有效。
3. SDIN数据输入,需要在时钟信号SCLK有效时开始发送数据,且在SCLK的正边缘取样, 注意,数据是从高位开始发送的。
知道了传送数据的时序,我们需要使用程序来模拟这个时序,从而发送指令控制液晶屏。
接下来,看看实例。
五、程序实例
代码一:
代码分析:
这个是一个写入一个字节数据的模拟时序函数,具有两个参数,dt为要写入的字节,command为数据/命令选择。
首先,需要sce拉低电平,开始发送数据。
i循环8次,写入8位数据,现以“设置扩展指令集”(即写入
0x21)全过程如下:
i = 0:dt = 0x21 = 0010 0001 b
dt & 0x80:
0010 0000
1000 0000 &
0000 0000 = 0,则sdin = 0 (DB7),
dt左移1位,dt<<1 = 0100 0010 b,
模拟时钟信号sclk = 0, sclk = 1,以使采样
∙i = 1: dt = 0100 0010b
dt & 0x80:
0100 0010
1000 0000 &
0000 0000 = 0, 则sdin = 0 (DB6),
dt左移1位,dt<<1 = 1000 0100 b,
模拟时钟信号sclk = 0, sclk = 1,以使采样
∙i = 2: dt = 1000 0100b
dt & 0x80:
1000 0100
1000 0000 &
1000 0000 != 0,则sdin = 1 (DB5),
dt左移1位,dt<<1 = 0000 1000 b,
模拟时钟信号sclk = 0, sclk = 1,以使采样
∙i = 3:dt = 0000 1000b
dt & 0x80:
0000 1000
1000 0000 &
0000 0000 = 0,则sdin = 0 (DB4),
dt左移1位,dt<<1 = 0001 0000 b,
模拟时钟信号sclk = 0, sclk = 1,以使采样
∙i = 4:dt = 0001 0000b
dt & 0x80:
0001 0000
1000 0000 &
0000 0000 = 0,则sdin = 0 (DB3),
dt左移1位,dt<<1 = 0010 0000 b,
模拟时钟信号sclk = 0, sclk = 1,以使采样
∙i = 5:dt = 0010 0000b
dt & 0x80:
0010 0000
1000 0000 &
0000 0000 = 0,则sdin = 0 (DB2),
dt左移1位,dt<<1 = 0100 0000 b,
模拟时钟信号sclk = 0, sclk = 1,以使采样
∙i = 6:dt = 0100 0000b
dt & 0x80:
0100 0000
1000 0000 &
0000 0000 = 0,则sdin = 0 (DB1),
dt左移1位,dt<<1 = 1000 0000 b,
模拟时钟信号sclk = 0, sclk = 1,以使采样
∙i = 7:dt = 1000 0000b
dt & 0x80:
1000 0000
1000 0000 &
1000 0000 != 0,则sdin = 1 (DB0),
dt左移1位,dt<<1 = 0000 0000 b,
模拟时钟信号sclk = 0, sclk = 1,以使采样
过程很罗嗦,不过很简单,呵呵~~
可见,这样循环8次,写入了8位数,DB7~DB0 = 0010 0001b = 0x20,正是“扩展指令集”的指令值。
代码二:
代码分析:
初始化步骤可以参照芯片手册中的编程示例:
代码三:
这些很容易理解,还原看一下:
上面的矩阵,就是一个字母"A",可见只要把这组值写入即可以显示“A”。
最后,到这里,我们已经学会了Nokia 5110液晶屏的原理和基本控制。
是不是觉得很简单。
呵呵~~~希望帮到大家,写得不好,请见谅,写的不对,望指正!
小Jay累了。