#include
#define uchar unsigned char
#define CS1 P2OUT |= BIT0 //串行LCD宏定义
#define CS0 P2OUT &=~BIT0
#define SID1 P2OUT |= BIT1
#define SID0 P2OUT &=~BIT1
#define SCLK1 P2OUT |= BIT2
#define SCLK0 P2OUT &=~BIT2
#define RST1 P2OUT |= BIT3
#define RST0 P2OUT &=~BIT3
//#define PSB0 P2OUT |= BIT4
//#define PSB1 P2OUT &=~BIT4
//函数声明
void InitSys();
void delay_ms(unsigned int);
void display_strings(void);
void displaydot(unsigned char x0,unsigned char y0 );
void lcdinit(void);
void clrgdram(void);
void write_com(unsigned char);
void write_data(unsigned char);
void sendbyte(unsigned char);
uchar ReadByte(void);
uchar Read_dos(uchar mode);
int flag=1;
char row1[]={"液晶显示屏12864 "};
char row2[]={"串行静态显示模式"};
char row3[]={"430LaunchpadBord"};
char row4[]={"只需四个IO口即可"};
char num[]={"0123456789"};
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; //关闭看门狗
InitSys(); //初始化
//display_strings(); //写入液晶中静态显示部分数据
//delay_ms(2000);
clrgdram();
displaydot(30,50);
displaydot(30,51);
displaydot(30,52);
displaydot(30,53);
displaydot(30,54);
}
/*****************************************************************************
系统初始化
******************************************************************************/
void InitSys()
{
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_8MHZ; // 设定工作频率为8M
DCOCTL = CALDCO_8MHZ; // Set DCO step + modulation */
P2DIR=0x1f;
lcdinit(); //LCD初始化
}
//毫秒级延时
void delay_ms(unsigned int nValue)//delay 1ms at 8M
{
unsigned int nCount;
unsigned int ii;
unsigned int jj;
nCount = 1980;
for(ii = nValue;ii > 0;ii--)
{
for(jj = nCount;jj > 0;jj--)
_NOP();
}
}
//液晶初始化
void lcdinit()
{
RST0;
delay_ms(10);
RST1;
delay_ms(200);
write_com(0x30); //功能设定:基本指令集
delay_ms(5);
write_com(0x0c); //显示状态:整体显示,游标关
delay_ms(5);
write_com(0x01); //清空显示
delay_ms(5);
}
//读一个字节
uchar ReadByte(void)
{
uchar i,temp;
CS1;
for(i=0;i