MSP430驱动LCD12864模块[KS0108]
作者:cxjr 摘自:匠人的百宝箱
以下是转载匠人的液晶点阵128x64模块程序,驱动芯片是KS0108。此芯片是较为常用的液晶模块芯片,在市面上使用较多。希望有兴趣的网友可以参考。谢谢cxjr。
如你有更好的源程序欢迎上传微控技术论坛。
//**********************************************
#include "msp430x14x.h" // Standard Equations
#include "math.h"
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "ctype.h"
#include "HZTable.h"
#include "ASCII816.h"
#define uint unsigned int
#define uchar unsigned char
//**********************************************
#define RS BIT0
#define RW BIT1
#define E BIT2
#define CS1 BIT3
#define CS2 BIT4
#define RST BIT5
#define EL BIT6 //背光
//数据线:p4口 ,控制线:p5口
//**********************************************
uchar cradd1,cradd2;
uchar item1[5]={0,1,2,3,50}; //欢迎使用
uchar item2[5]={4,5,6,7,50}; //请等待……
//=======================================================
void short_delay(uint i)
{ uint j;
for(j=0;j<=i;j++);
}
void delayms(uchar tickms)
{ uchar count,i;
_NOP();
_NOP();
_NOP();
for(i=tickms;i>0;i--)
{ for(count=0;count<=58;count++) {;}
_NOP();
}
}
//**************************************************
void prl0(uchar com1)// 写指令代码子程序(左)
{
P5DIR|=0X7F; //P5为输出口
P5OUT|=CS1; //csa=1
P5OUT&=~CS2; //csb=0
P5OUT&=~RS;
P5OUT|=RW; //RS=0,R/W=1,以便读液晶状态
P4DIR=0x00; //P4口为输入口
do
{
P5OUT|=E; //E=1
cradd1=P4IN;