您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 人事档案/员工关系 > PG160128LCD程序移植与驱动笔记-T6963
PG160128LCD程序移植与驱动笔记PART1PG160128的硬件结构与特性LCD的尺寸参数驱动电路引脚分配与功能电气参数内部RAM结构仿真模型RAM结构与图中不同,Proteus仿真模型RAM为8kByte,地址连续。TextRAM与图形RAM分配可联系分配。液晶控制时序T6963C时序参数表Vdd=5.0V±10%,Vss=0VTa=-10℃-70℃指令表T6963C的状态字由七位标志位组成,它们是:驱动流程状态检查数据发送在使用T6963C时,都是先发送数据,后发送命令。命令发送步骤设置光标位置(21H)光标位置由X、Y地址来确定,光标的移动只能用该命令实现。从MPU读写数据是不会改变光标位置的。X、Y的值由下面指定:X地址:00H~4FH(低7位有效)(0~80列)Y地址:00H~1FH(低5位有效)(0~32行)设置地址指针(24H)设置文本区起始地址(40H)设置图形区起始地址(42H)设置文本区宽度(41H)设置图形区宽度(43H)模式设置命令自动读模式(0xB1)自动写模式(0xB0)T6963C允许用户定义256个自定义的字符,存放于CGRAM当中,当然也是放置在连接的显存上,它的具体的位置(起始地址SGADDR)可以由用户通过指令来设置,最大管理2Kbyte的CGRAM。CGRAM当中,总是8个bytes为一个自定义字符的字模数据存储区,也就是每8个bytes对应着一个从0x00到0xFF之间的字符编号。移植驱动程序来源(画点部分):Proteus安装目录E:\ProgramFiles\LabcenterElectronics\Proteus7Professional\SAMPLES\VSMforARM7\LPC2138withGraphicsLCD移植驱动程序来源(画线部分):AVRman_2011-3-29_移植驱动程序来源(画圆部分):正点原子STM32TFT驱动代码液晶驱动宏定义/*Privatedefine------------------------------------------------------------*/#defineWIDTH16//Displaywidth#defineADDR_W0x0000//Textdisplaybufferbaseaddress#defineADDR_T0x0100//Graphicsdisplaybufferbaseaddress//T6963CPindefinition;#defineLCD_WRPin_0#defineLCD_RDPin_1#defineLCD_CEPin_2#defineLCD_CDPin_3#defineLCD_RSTPin_4#defineLCD_FS1Pin_5#defineLCD_DIRCDDRC#defineLCD_CREGPORTC#defineLCD_PINDPIND#defineLCD_DIRDDDRD#defineLCD_DATAPORTD#defineLCD_BF0(10)#defineLCD_BF1(11)#defineLCD_BF3(13)/*Privatemacro-------------------------------------------------------------*/#defineSET_1(Pinx)(LCD_CREG|=Pinx)#defineSET_0(Pinx)(LCD_CREG&=~Pinx)#defineSET_IN(REG,Pinx)(REG&=~Pinx)#defineSET_OUT(REG,Pinx)(REG|=Pinx)私有变量定义/*Privatevariables---------------------------------------------------------*///Loadingdecimaltransformresult;staticu8dec_table[10]={'0','0','0','0','0','.','0','0','0',0};//staticu8Lcd_RAMdata[128][16]={0x00};staticconstu8Table_Sin[46]={0,4,7,11,14,17,21,24,28,31,34,38,41,44,47,50,53,56,59,62,64,67,70,72,74,77,79,81,83,85,87,88,90,91,93,94,95,96,97,98,98,99,99,99,100,100};绘制点函数包括:检查液晶忙碌状态﹑写数据﹑写命令﹑清屏实现原理:/*---------------------------------------------------------------------------*\**-Fun--LCD_Init().**-Des--Clearscreen.**-Par--None.**-Ret--None.**-Inf--None.\*---------------------------------------------------------------------------*/voidLCD_Init(void){SET_OUT(LCD_DIRC,Pin_0|Pin_1|Pin_2|Pin_3|Pin_4|Pin_5);SET_OUT(LCD_DIRD,Pin_All);SET_0(LCD_RST);SET_1(LCD_RST);delay_ms(100);SET_0(LCD_CE);SET_1(LCD_WR);SET_1(LCD_RD);LCD_WriteShort(ADDR_W,0x40);//SettextdisplaybufferbaseaddressLCD_WriteShort(ADDR_T,0x42);//SetgraphicsdisplaybufferbaseaddressLCD_WriteWord(WIDTH,0x00,0x41);//SettextdisplaywidthLCD_WriteWord(WIDTH,0x00,0x43);//SetgraphicsdisplaywidthLCD_WriteCommand(0x81);//Setdisplaymode:textxorgraphicsLCD_WriteWord(0x56,0x00,0x22);//SetCGRAMoffsetaddressLCD_WriteCommand(0x9c);//Settextandgraphicdisplayon}/*----------------------------------------------------------------------------*\**-Fun--LCD_CheckBusy().**-Des--Testbusyflag.**-Par--None.**-Ret--None.\*----------------------------------------------------------------------------*/voidLCD_CheckBusy(u8autowr){LCD_DATA=0xFF;SET_1(LCD_CD);SET_1(LCD_WR);SET_IN(LCD_DIRD,Pin_All);SET_0(LCD_RD);if(autowr){while((LCD_PIND&LCD_BF3)==0);}else{while((LCD_PIND&LCD_BF0)==0||(LCD_PIND&LCD_BF1)==0);}SET_1(LCD_RD);SET_OUT(LCD_DIRD,Pin_All);}/*----------------------------------------------------------------------------*\**-Fun--LCD_WriteCommand().**-Des--Writecommand.**-Par--None.**-Ret--None.\*----------------------------------------------------------------------------*/voidLCD_WriteCommand(u8comm){LCD_CheckBusy(0);SET_1(LCD_CD);SET_1(LCD_RD);LCD_DATA=comm;SET_0(LCD_WR);SET_1(LCD_WR);}/*----------------------------------------------------------------------------*\**-Fun--LCD_WriteData().**-Des--Writedata.**-Par--None.**-Ret--None.\*----------------------------------------------------------------------------*/voidLCD_WriteData(u8dat){LCD_CheckBusy(0);SET_0(LCD_CD);SET_1(LCD_RD);LCD_DATA=dat;SET_0(LCD_WR);SET_1(LCD_WR);}/*----------------------------------------------------------------------------*\**-Fun--LCD_WriteByte().**-Des--WritedataorcommandtoLCD.**-Par--None.**-Ret--None.**-Inf--Writeonebytedataandonebytecommand.\*----------------------------------------------------------------------------*/voidLCD_WriteByte(u8dat,u8comm){LCD_WriteData(dat);LCD_WriteCommand(comm);}/*----------------------------------------------------------------------------*\**-Fun--LCD_WriteWord().**-Des--WritedataorcommandtoLCD.**-Par--None.**-Ret--None.**-Inf--Writetwobytesdataandonebytecommand.\*----------------------------------------------------------------------------*/voidLCD_WriteWord(u8datl,u8dath,u8comm){LCD_WriteData(datl);LCD_WriteData(dath);LCD_WriteCommand(comm);}/*----------------------------------------------------------------------------*\**-Fun--LCD_WriteShort().**-Des--Writea16bitsdataandonebytecommand.**-Par--None.**-Ret--None.\*----------------------------------------------------------------------------*/voidLCD_WriteShort(u16dat,u8comm){LC
本文标题:PG160128LCD程序移植与驱动笔记-T6963
链接地址:https://www.777doc.com/doc-4838368 .html