《实验十五 点阵LCD液晶显示屏实验.docx》由会员分享,可在线阅读,更多相关《实验十五 点阵LCD液晶显示屏实验.docx(11页珍藏版)》请在三一办公上搜索。
1、实验十五点阵LCD液晶显示屏实验一、实验目的:学习获取字模的方法;学习122X32A液晶LCD的原理及编程方法;二、实验内容:在LCD上显示字样。三、实验器材:1、单片机综合实验仪 1 台2、KEIL仿真器1台3、连线若干根4、计算机1台四、工作原理:1、我们选用的122X32A点阵式液晶LCD,是内置SED1520液晶显示控制器 的屏,它集行、列驱动器和控制器于一体,被广泛应用于小规模液晶显示模块中。SED1520 内置2560位显示RAM区,RAM中的1位数据控制液晶屏上一个象素的亮、暗,“1”为亮,“0” 为暗。它具有16个行驱动输出和61个列驱动输出,可以直接与80系列或68系列的CP
2、U 相连,驱动占空比为1/32,显示内容:122X32点。2、122X32A点阵式液晶LCD电路图:122X16DOTS2o o1122X16DOTS16153、极限参数:引脚歹Zyczi符号电平说明1VDD5. 0V电源电压2GND0V接地(GND)3V0可调LCD驱动电压(对比度调节)4/RESH/L复位信号5E1H,HL片使能信号16E2H,HL片使能信号27R/WH/LH:读;L:写8A0H/LH:数据;L:指令9DB0H/L数据位010DB1H/L数据位111DB2H/L数据位212DB3H/L数据位313DB4H/L数据位414DB5H/L数据位515DB6H/L数据位616DB7
3、H/L数据位7名称czi符号测试条件标准值单位最小值最大值电源电压v_-v 一Ta=25C06. 5VLCD驱动电压DD CCV -v012. 0V输入电压DD0V0V V4、电参数:名称czi 符号测试条件标准值单位最小值典型值最大值电压逻辑V -V-4. 755. 05. 25VLCDDDSSV -V-4. 55. 56. 5V电流逻辑DD0I-2. 5-mALCDDDI-2. 0-mALCD工作电压EEVdd-V00C-6. 2-V25 C-5. 5-v(推荐彳首)40 C-4. 8-v输入电压高电平v高电平0. 7V-Vv低电平IHV低电平DD0-DD0. 3Vddv5、Read/Wr
4、ite Timing for the 80-port MPU(Ta=0 to 75C,Vss=.0V 0%)A0, /CS/WR, /RDD0 - D7 (WRITE)D0 - D7(READ)ParameterSignalSymbolConditionRatingUnitMinTypeMaxAddress hold timeA0,t10-nsAddress set-up time/CSAH8t20-nsSystem cycle time/WR,AW8 t1000-nsControl pulse width/RDcyc8tcc200-nsData Set-up timet80-nsData h
5、old timeD0-D7DS8t10-nsRD access timeDH8 tCL=100PF-90nsOutput disable timeACC8t10-60nsThe ratings when Vss=.0V are approximately 100% higher than when Vss=.0V.6、Control timimg for 80 - port/68 - port display(Ta = 0 to 7C, Vss = .0V 0 %)CLParameterSignalSymbolConditionRatingUnitMinTypeMaxLOW pulse wid
6、thCLt35-nsHIGH pulse widthWLCLt35-nsRising timeWHCLt-30150nsFalling timeR t-30150nsFR delay timeFRFtDFRInput timing-2.00.22.0nsOuput timingCl=100pf-0.20.4ns7、指令功能:SED1520有13条指令,从作用上可分为两大类:一类为显示方式的设置 指令,前6条指令为这一类指令,它们只需在初始化程序中写入一次即可。另一类为显示数 据读/写操作的指令,从第7条往下(包括读状态字)都是这类指令。CommandRDWRA0D7D6D5D4D3D2D1D0
7、1Display ON/OFF10010101110/12Display START Line100110Display START address(0-31)3Page Address Set100101110Page(0-3)4Column(Segment)Address Set1000Column address (0-79)5Status Read010BUSYACCON/OFFRET00006Write Display Data101Write Data7Read Display Data011Read Data8ADC Select10010100000/19Static Driv
8、e ON/OFF10010100100/110Duty Select10010101000/111Read Modify Write1001110000012End1001110111013Reset10011100010COM1: Switches the entire display ON or OFF,regardless of the Display RAM dataFRC一or the internal status*COM2: Determines the line of RAM data to be displayed at the display top lineCOM3: S
9、ets the page of the Display RAM in the page address registerCOM4: Sets the column address of the Display RAM in the column address registerCOM5: Reads the statusBUSY 1: Busy(internal processing) 0: READY statusADC1:Rightward(forward)output0:leftward(reverse)outputON/OFF 1: Display OFF0: Display ONRE
10、T1:Resetting0:NormalCOM6:Writes thedata on the databusto RAMCOM7:Reads datafrom the DisplayRAMontothedata busCOM8: Used to reverse the correspondence between the Display RAM column address and segment driver output ports0: Rightward(forward)output 1: leftward(reverse)outputCOM9: Selects normal displ
11、ay operation or static all-lit drive displayoperation.1: Static drive(Power Save)*0: Normal display operationCOM10: Selects the duty factor for driving LCD cells1: 1/32 duty0: 1/16 dutyCOM11: Increments the column address counter by one only when display data written but not when it is read.COM12: C
12、ancels the Ready Modify Write ModeCOM13: Resets the Display START line to the 1st line in the register.Resets the column address counter to 0 and page address register to 3五、接线方案:调用显示“品”字子程IlIlTIInRSl /T1. 口口口口皿皿JZIJnm V & V.I.J EERAkKRkKRkKLCD显示子程序:LCD液晶显示清屏子程序:七、实验步骤:1、设定仿真模式为程序空间在仿真器上,数据空间在用户板上。2
13、、系统分配给 LCD 的地址为:0FA00H-0FBFFH,0F800H-0F9FFH3、设计称序并执行,观察结果。八、思考问题:1、显示“思考问题”字样。2、修改程序,使其上、下、左、右移动。九、实验连线:无连线。十、实验程序:;中文LCD,参阅书.显示字符#include reg51.h#include absacc.h”#include intrins.h”#define PD1 61/* 122/2 分成左右两半屏(122x32) */unsigned char Column;unsigned char Page_ ;/* 页地址寄存器 D1,DO:页地址 */unsigned cha
14、r Code_ ;/* 字符代码寄存器 */unsigned char Command; /* 指令寄存器 */unsigned char LCDData; /* 数据寄 存器 */#define CWADD1#define DWADD1#define CRADD1#define DRADD1XBYTEXBYTEXBYTEXBYTE_0xfa00_0xfa40_0xfa80_0xfac0_/*写指令代码地址(E1) */*写显示数据地址(E1) */*读状态字地址(E1) */*读显示数据地址(E1) */#define#define#define#define#defineCWADD2DWA
15、DD2CRADD2DRADD2XBYTEXBYTEXBYTEXBYTEPxf800Pxf8400xf880_0xf8c0_Nop() _nop_ ();/*写指令代码地址(E/2/*写显示数进地址(E/*读状态字地址(E2/*读显示数据地址(E2nop_ (); _nop_ (); _nop_ (); _nop()/*中文字模库16x16点阵*/unsigned char code CCTAB32 = /* 点阵:16x16提取点阵方向:纵向字节掉转:是字节方式:C语言*/0x20,0x20,0x24,0x24,0x24,0xE4,0x26,0x24,/0x20,0xFF,0x20,0x22,
16、0x2C,0x20,0x20,0x00,0x20,0x60,0x3F,0x20,0x20,0x1F,0x11,0x11,0x10,0x03,0x1C,0x20,0x40,0x80,0xE0,0x00,0x10,0x22,0x64,0x0C,0x80,0x04,0x74,0x84,/0x04,0x04,0x04,0xC4,0x3E,0x04,0x00,0x00,0x04,0x04,0x7E,0x01,0x80,0x40,0x20,0x11,0x0A,0x04,0x0B,0x10,0x60,0xC0,0x40,0x00,0x80,0x70,0x00,0xFF,0x10,0x22,0xF2,0x92
17、,/0x92,0x92,0x92,0x92,0xFB,0x12,0x00,0x00,0x00,0x00,0x00,0xFF,0x20,0x20,0x27,0x24,0x24,0x24,0x24,0x24,0x27,0x30,0x20,0x00,0x24,0x24,0x24,0xA4,0xFE,0xA3,0x22,0x00,/0x24,0x48,0x00,0xFF,0x00,0x80,0x00,0x00,0x10,0x08,0x06,0x01,0xFF,0x00,0x01,0x02,0x02,0x02,0x02,0xFF,0x01,0x01,0x01,0x00,0x00,0xF8,0x48,0x
18、48,0x48,0x48,0xFF,0x48,/0x48,0x48,0x48,0xFC,0x08,0x00,0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x3F,0x42,0x42,0x42,0x42,0x47,0x40,0x70,0x00,0x00,0x80,0x80,0x82,0x82,0x82,0x82,0x82,0xE2,/0xA2,0x92,0x8A,0x86,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
19、0x00,0x20,0x24,0x24,0xA4,0xFF,0xA4,0xB4,0xAC,/0x20,0x9F,0x10,0x10,0xF0,0x18,0x10,0x00,0x02,0x12,0x51,0x90,0x7E,0x0A,0x89,0x40,0x20,0x1B,0x04,0x1B,0x60,0xC0,0x40,0x00,0x80,0x40,0x20,0xF8,0x07,0x00,0x38,0xC0,/0x02,0x04,0x0C,0x80,0x60,0x1C,0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0x40,0x20,0x10,0x0B,0x04,0x0
20、A,0x11,0x60,0xC0,0x40,0x00,;/* 1.写指令代码子程序(E1) */void WriteCommandE1()一/while(IN(CRADD1) & 0x80);/实际的液晶操作中可以不判断是否忙CWADD1=Command;_Nop();/* 2.写显示数据子程序(E1) */void WriteDataE1()/while(IN(CRADD1) & 0x80);DWADD1=LCDData;_Nop();/* 4.写指令代码子程序(E2) */void WriteCommandE2()/while(IN(CRADD2) & 0x80);CWADD2=Comma
21、nd;_Nop();/* 5.写显示数据子程序(E2) */ void WriteDataE2() /while(IN(CRADD2) & 0x80);DWADD2=LCDData;_Nop(); /*初始化程序*/void Init()Command = 0xe2;WriteCommandE1();WriteCommandE2();Command = 0xa4;WriteCommandE1();WriteCommandE2();Command = 0xa9;WriteCommandE1();WriteCommandE2();Command = 0xa0;WriteCommandE1();Wr
22、iteCommandE2();Command = 0xc0;WriteCommandE1();WriteCommandE2();Command = 0xaf;WriteCommandE1();WriteCommandE2();/*清屏*/void Clear()unsigned char i,j;i = 0;do Command = (i + 0xb8);/* 页地址设置 */WriteCommandE1();WriteCommandE2();Command = 0x00;/* 列地址设置为0 */WriteCommandE1();WriteCommandE2();j = 0x50;/* 一页
23、清80个字节*/do LCDData = 0x00;/* 显示数据为0 */WriteDataE1();WriteDataE2();while(-j !=0);/*页内字节清零循环*/while(+i !=4);/*页地址暂存器加一 */*显示区清零循环*/*延时函数*/void delay()unsigned int i;for(i=0;i=5000;i+);/*中文显示子程序*/void WriteCHN16x16()unsigned char i,j,k;i = 0;j = 0;while(j2) Command = (Page_ + j) & 0x03)WriteCommandE1()
24、;WriteCommandE2();k = Column;while(k Column + 16)if (k = PD1 * 2) break;j+;char code dx5163 _at_ 0x003b;/* 中文显示程序 */void main()Init();Clear();while(1)Clear();Page_ = 0x02;Column = 0x20;Code_ = 0x00;WriteCHN16x16();| 0xb8;/*设置页地址*/*列地址值*/*为左半屏显示区域(E1) */*设置列地址值*/*取汉字字模数据*/*写字模数据J/*为右半屏显示区域(E2) */*设置列
25、地址值*/i; /*取汉字字模数据*/*写字模数据*/*列地址是否超出显示范围*/Page_ = 0x02;Column = 0x30;Code_ = 0x01;WriteCHN16x16();Page_ = 0x02;Column = 0x40;Code_ = 0x02;WriteCHN16x16();Page_ = 0x02;Column = 0x50;Code_ = 0x03;WriteCHN16x16();Page_ = 0x00;Column = 0x20;Code_ = 0x04;WriteCHN16x16();Page_ = 0x00;Column = 0x30;Code_ = 0x05;WriteCHN16x16();Page_ = 0x00;Column = 0x40;Code_ = 0x06;WriteCHN16x16();Page_ = 0x00;Column = 0x50;Code_ = 0x07;WriteCHN16x16();delay();