//******************************************************************************
//ZhaoZhendong
//Lierda, Inc
//July 2004
//Built with IAR Embedded Workbench Version: 3.20A
//******************************************************************************
#include "msp430x44x.h"
//******************************************************************************
//显示的字体要与定义的数组相符
#define HANZI_HIGHTH 16 //定义汉字的高度
#define HANZI_WIDETH 19 //定义汉字的宽度
#define CHAR_HIGHTH 8 //定义字符的高度
#define CHAR_WIDETH 5 //定义字符的宽度
#define ICON_HIGHTH 16 //定义图标的高度
#define ICON_WIDETH 16 //定义图标的宽度
//******************************************************************************
#define hAddr 34
const unsigned char CHAR_0[5]={0x3E,0x51,0x49,0x45,0x3E};
const unsigned char CHAR_1[5]={0x00,0x42,0x7F,0x40,0x00};
const unsigned char CHAR_2[5]={0x42,0x61,0x51,0x49,0x66};
const unsigned char CHAR_3[5]={0x23,0x41,0x45,0x4B,0x31};
const unsigned char CHAR_4[5]={0x18,0x14,0x52,0x7F,0x50};
const unsigned char CHAR_5[5]={0x27,0x45,0x45,0x45,0x39};
const unsigned char CHAR_6[5]={0x3C,0x4A,0x49,0x49,0x30};
const unsigned char CHAR_7[5]={0x03,0x71,0x09,0x05,0x03};
const unsigned char CHAR_8[5]={0x36,0x49,0x49,0x49,0x36};
const unsigned char CHAR_9[5]={0x06,0x49,0x49,0x29,0x1E};
const unsigned char CHAR_A[5]={0x7E,0x11,0x11,0x11,0x7E};
const unsigned char CHAR_B[5]={0x7F,0x49,0x49,0x49,0x36};
const unsigned char CHAR_T[5]={0x03,0x41,0x7F,0x41,0x03};
const unsigned char CHAR_E[5]={0x41,0x7F,0x49,0x5D,0x63};
const unsigned char CHAR_L[5]={0x41,0x7F,0x41,0x40,0x60};
const unsigned char Symbols[20][5]=
{
/*-- 符号: ':'和'-' --*/
/*-- 对应的点阵为:宽x高=5x8 --*/
0x00,0x36,0x36,0x00,0x00,// [0]':'
0x00,0x08,0x08,0x08,0x00// [1]'-'
};
const unsigned char Lierda_13_19[3][38]=
{
/*-- 文字: 利 --*/
/*-- 隶书; 此字体下对应的点阵为:宽x高=19x13 --*/
0x00,0x10,0x92,0x92,0xD2,0x72,0xFE,0xFB,0x53,0x93,0x90,0x00,0xFC,0xFC,0x00,0x07,0xFF,0xC2,0x00,
0x03,0x03,0x03,0x01,0x00,0x00,0x1F,0x0F,0x00,0x00,0x00,0x08,0x08,0x18,0x18,0x0C,0x0F,0x07,0x00,
/*-- 文字: 尔 --*/
/*-- 隶书; 此字体下对应的点阵为:宽x高=19x13 --*/
0x00,0x10,0x10,0x18,0x08,0x8C,0xC7,0x47,0x04,0xFC,0xFC,0x04,0x44,0xC4,0x84,0x0C,0x7C,0x00,0x00,
0x04,0x04,0x06,0x03,0x03,0x01,0x0C,0x08,0x18,0x1F,0x0F,0x00,0x00,0x00,0x01,0x07,0x0E,0x0E,0x04,
/*-- 文字: 达 --*/
/*-- 隶书; 此字体下对应的点阵为:宽x高=19x13 --*/
0x00,0x30,0x16,0x16,0x76,0xB4,0x08,0x08,0x0C,0x8C,0xCC,0x7F,0x3F,0x44,0xC4,0x84,0x04,0x00,0x00,
0x06,0x02,0x02,0x02,0x03,0x03,0x02,0x03,0x07,0x05,0x04,0x04,0x0C,0x0C,0x0C,0x1D,0x1F,0x0C,0x0C
};
const unsigned char LSD_ICON[32]=
{
/*-- LSD; 此字体下对应的点阵为:宽x高=19x13 --*/
0xE0,0xF0,0xFC,0xFE,0x00,0x9F,0x3F,0x71,0xE7,0xCF,0x00,0xFE,0x0C,0x1C,0xF0,0xE0,
0x07,0x0F,0x3F,0x3F,0x70,0xF7,0xF7,0xF4,0xF7,0xF7,0x00,0x7F,0x38,0x38,0x0F,0x07
};
extern void lcd_init(void);
extern void write_command(unsigned char command);
extern void clear_lcd(void);
extern void display( unsigned char *chr, unsigned char nRow, unsigned char nCol,
unsigned char highth,unsigned char wideth );
void show(void);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
FLL_CTL0 |= XCAP14PF;
show();
_EINT();
while(1)
{
_BIC_SR(LPM3);
_NOP();
_NOP();
}
}
void show(void)
{
lcd_init();
write_command(0xC0);
write_command(0x3F);
clear_lcd();
display((unsigned char *)&LSD_ICON[0],1,5,ICON_HIGHTH,ICON_WIDETH);
display((unsigned char *)&Lierda_13_19[0][0],3,30,HANZI_HIGHTH,HANZI_WIDETH);
display((unsigned char *)&Lierda_13_19[1][0],3,60,HANZI_HIGHTH,HANZI_WIDETH);
display((unsigned char *)&Lierda_13_19[2][0],3,90,HANZI_HIGHTH,HANZI_WIDETH);
display((unsigned char *)&CHAR_T[0],6,16,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_E[0],6,22,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_L[0],6,28,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&Symbols[0][0],6,hAddr,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_0[0],6,hAddr+6,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_5[0],6,hAddr+12,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_7[0],6,hAddr+18,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_1[0],6,hAddr+24,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&Symbols[1][0],6,hAddr+30,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_8[0],6,hAddr+36,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_8[0],6,hAddr+42,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_2[0],6,hAddr+48,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_5[0],6,hAddr+54,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_9[0],6,hAddr+60,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_4[0],6,hAddr+66,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_7[0],6,hAddr+72,CHAR_HIGHTH,CHAR_WIDETH);
display((unsigned char *)&CHAR_4[0],6,hAddr+78,CHAR_HIGHTH,CHAR_WIDETH);
}
//******************************************************************************
//ZhaoZhendong
//Lierda, Inc
//July 2004
//Built with IAR Embedded Workbench Version: 3.20A
//******************************************************************************
#include "LCD_DEFINE.H"
void lcd_init(void)
{
LCD_DATA_OUT = 0x00;
LCD_DATA_DIR = 0xFF;
LCD_CON_OUT = LCD_CS1+LCD_CS2+LCD_RST;
LCD_CON_DIR |= LCD_DI+LCD_RW+LCD_EN+LCD_CS1+LCD_CS2+LCD_RST;
LCD_CON_OUT &= ~LCD_RST;
_NOP();
_NOP();
LCD_CON_OUT |= LCD_EN;
_NOP();
_NOP();
LCD_CON_OUT &= ~LCD_EN;
_NOP();
_NOP();
LCD_CON_OUT |= LCD_RST;
_NOP();
_NOP();
}
void write_command(unsigned char command)
{
LCD_DATA_DIR = 0xFF;
LCD_CON_OUT |= LCD_CS1 + LCD_CS2;
LCD_CON_OUT &= ~(LCD_RW + LCD_DI);
LCD_DATA_OUT = command;
LCD_CON_OUT |= LCD_EN;
LCD_CON_OUT &= ~LCD_EN;
}
void write_data( unsigned char data, unsigned char CS1, unsigned char CS2 )
{
LCD_DATA_DIR = 0xFF;
if(CS1) LCD_CON_OUT |= LCD_CS1;
else LCD_CON_OUT &=~LCD_CS1;
if(CS2) LCD_CON_OUT |= LCD_CS2;
else LCD_CON_OUT &=~LCD_CS2;
LCD_CON_OUT |= LCD_DI;
LCD_CON_OUT &=~LCD_RW;
LCD_DATA_OUT = data;
LCD_CON_OUT |= LCD_EN;
LCD_CON_OUT &=~LCD_EN;
}
void clear_lcd(void)
{
unsigned char i,j;
for(i=0;i<8;i++)
{
write_command(SET_X|i);
write_command(SET_Y);
for(j=0;j<128;j++)
{
if(j<=63)write_data(0,1,0);
else write_data(0,0,1);
_NOP();
}
}
}
void display( unsigned char *chr, unsigned char nRow, unsigned char nCol,
unsigned char highth,unsigned char wideth )
//*chr 显示数据的地址,nRow 在显示屏上第几行,nCol 在显示屏上第几列
//highth 字体的高度,wideth 字体的宽度
//128*64有8行,128列
{
unsigned char i,tmpCol,tmpRow,h,m;
unsigned int j=0;
tmpRow = nRow;
m=0;
for(h=0;h<highth;h=h+8)
{
write_command(SET_X|tmpRow);
tmpCol=nCol;
for(i=0;i<wideth;i++)
{
if(tmpCol<64)
{write_command(SET_Y|tmpCol);write_data(chr[i+j],1,0);}
else
{write_command(SET_Y|(tmpCol-64));write_data(chr[i+j],0,1);}
tmpCol++;
}
m++;
j=m*wideth;
tmpRow++;
}
}
//******************************************************************************
//ZhaoZhendong
//Lierda, Inc
//July 2004
//Built with IAR Embedded Workbench Version: 3.20A
//******************************************************************************
//与硬件有关的定义:数据口用的是P3口,控制口用的是P2口,
//如果不同,可以更改以下定义。
#include "msp430x44x.h"
#define LCD_CON_DIR P2DIR
#define LCD_CON_OUT P2OUT
#define LCD_DI BIT0
#define LCD_RW BIT1
#define LCD_EN BIT2
#define LCD_CS1 BIT3
#define LCD_CS2 BIT6
#define LCD_RST BIT7
#define LCD_DATA_DIR P3DIR
#define LCD_DATA_IN P3IN
#define LCD_DATA_OUT P3OUT
#define LCD_DATA_BIT0 BIT0
#define LCD_DATA_BIT1 BIT1
#define LCD_DATA_BIT2 BIT2
#define LCD_DATA_BIT3 BIT3
#define LCD_DATA_BIT4 BIT4
#define LCD_DATA_BIT5 BIT5
#define LCD_DATA_BIT6 BIT6
#define LCD_DATA_BIT7 BIT7
//*****************************************************************
//以下为LCD的命令字
#define DISPLAY_ON 0x3F //显示屏开命令字
#define DISPLAY_OFF 0x3E //显示屏关命令字
#define SET_SHOW 0xC0 //设定显示起始行命令字
#define SET_X 0xB8 //设定显示行命令字
#define SET_Y 0x40 //设定显示列命令字