原创 字符型LCD12864 MSP430程序

2007-7-8 13:11 3501 9 7 分类: MCU/ 嵌入式

字符型LCD12864 MSP430程序


MSP430高级开发板上的字符型LCD12864程序

MSP430高级开发板: >>点击进入

欢迎转载本站程序 请注明来自于www.just430.cn

 


/**********************************************************/
//MSP430 Advanced Developping Components - [LCD12864A_430.C]
////->>> http://www.just430.cn
////->>> tel 0)13500717874
/**********************************************************/
//MSP430高级实验开发组件 - LCD12864(字符型)液晶显示驱动
/*********************************************************/


#include


#define LCD_DI   BIT7   //LCD_DI -> P2.7
#define LCD_DI_DIR  P2DIR
#define LCD_DI_LO  P2OUT &= ~LCD_DI
#define LCD_DI_HI  P2OUT |= LCD_DI


#define LCD_RW   BIT6   //LCD_RW -> P2.6
#define LCD_RW_DIR  P2DIR
#define LCD_RW_LO  P2OUT &= ~LCD_RW
#define LCD_RW_HI  P2OUT |= LCD_RW


#define LCD_EN   BIT5   //LCD_EN -> P2.5
#define LCD_EN_DIR  P2DIR
#define LCD_EN_LO  P2OUT &= ~LCD_EN
#define LCD_EN_HI  P2OUT |= LCD_EN


#define LCD_PSB   BIT0   //LCD_CS1 -> P6.0//PSB
#define LCD_PSB_DIR  P6DIR
#define LCD_PSB_LO  P6OUT &= ~LCD_PSB
#define LCD_PSB_HI  P6OUT |= LCD_PSB


#define LCD_RST   BIT2   //LCD_RST -> P6.2
#define LCD_RST_DIR  P6DIR
#define LCD_RST_LO  P6OUT &= ~LCD_RST
#define LCD_RST_HI  P6OUT |= LCD_RST


#define LCD_DATA_IN  P5IN
#define LCD_DATA_OUT  P5OUT
#define LCD_DATA_DIR  P5DIR


void LCD_Init(void);
void LCD_CheckBusy(void);
void LCD_Delayt(unsigned int dtime);
void LCD_WriteComm(unsigned char wdata);
void LCD_WriteByte(unsigned char wdata);
void LCD_SetXY(unsigned char X, unsigned char Y);
void LCD_WriteDEC(unsigned char X, unsigned char Y, unsigned char wdata);
void LCD_WriteString(unsigned char X, unsigned char Y, unsigned char *String);


unsigned char *aaa = "这是第一行吗?";


/*****************************************
void main(void) {
 WDTCTL = WDTPW + WDTHOLD;
 
 LCD_Init();
 LCD_WriteComm(0x01);
 
 while(1) {
  LCD_WriteString(1,1,aaa);
  LCD_Delayt(50000);LCD_Delayt(50000);LCD_Delayt(50000);LCD_Delayt(50000);
  LCD_WriteString(1,1,"这是第一行的!");
  LCD_Delayt(50000);LCD_Delayt(50000);LCD_Delayt(50000);LCD_Delayt(50000);
 }
}
*****************************************/


void LCD_Delayt(unsigned int dtime) {
 unsigned int itemp;
 for(itemp=0;itemp}


void LCD_Init(void) {
 LCD_PSB_DIR |= LCD_PSB;   //PSB -> 并行模式
 LCD_PSB_HI;
 
 LCD_RST_DIR |= LCD_RST;   //RST -> 复位输出
 LCD_RST_LO;    //复位状态
 LCD_Delayt(1000);
 
 LCD_DI_DIR |= LCD_DI;
 LCD_DI_LO;
 LCD_RW_DIR |= LCD_RW;
 LCD_RW_LO;
 LCD_EN_DIR |= LCD_EN;
 LCD_EN_LO;
 
 LCD_Delayt(1000);
 LCD_RST_HI;    //正常状态
 
 LCD_WriteComm(0x30);
 LCD_WriteComm(0x0c);
 LCD_WriteComm(0x01);
 LCD_WriteComm(0x02);
 LCD_WriteComm(0x06);
}


void LCD_CheckBusy(void) {
 unsigned char Flag;
 LCD_DI_LO;
 LCD_RW_HI;
 LCD_DATA_DIR = 0x00;
 do {
  LCD_EN_HI;
  Flag = LCD_DATA_IN;
  LCD_EN_LO;
 } while(Flag & 0x80);
 LCD_DATA_DIR = 0xFF;
}


void LCD_WriteComm(unsigned char wdata) {
 LCD_CheckBusy();
 
 LCD_DI_LO;
 LCD_RW_LO;
 LCD_EN_HI;
 
 LCD_DATA_OUT = wdata;
 LCD_EN_LO;
}


void LCD_WriteByte(unsigned char wdata) {
 LCD_CheckBusy();
 
 LCD_DI_HI;
 LCD_RW_LO;
 LCD_EN_HI;
 
 LCD_DATA_OUT = wdata;
 LCD_EN_LO;
}



void LCD_SetXY(unsigned char X, unsigned char Y) {
 switch(Y) {
  case 1:
   LCD_WriteComm(0x7F + X);
   break;
  case 2:
   LCD_WriteComm(0x8F + X);
   break;
  case 3:
   LCD_WriteComm(0x87 + X);
   break;
  case 4:
   LCD_WriteComm(0x97 + X);
 }
}


void LCD_WriteDEC(unsigned char X, unsigned char Y, unsigned char wdata) {
 LCD_SetXY(X,Y);
 LCD_WriteByte(wdata);
}


void LCD_WriteString(unsigned char X, unsigned char Y, unsigned char *String) {
     unsigned char temp;
 LCD_SetXY(X,Y);
 temp = *String;
 while(temp!=0) {
      LCD_WriteByte(temp);
      temp = *(++String);
 } 
}

文章评论1条评论)

登录后参与讨论

用户1613410 2009-5-5 17:06

不错,学习
相关推荐阅读
用户88827 2008-07-12 15:09
播放MP3的LPC板子Music-LPC2103: LPC2103 + VS1003 + LCD +
Music-LPC2103的PCB终于回来了 但是这次作的很少 不过还好 没有任何BUG出现 我发现画双面板很多时候要比4层的麻烦多的现在就把他的图片放出来吧介绍一下这个不大不小的东西ARM7TDMI...
用户88827 2008-06-06 19:44
taobao 一个钻了 哈哈
恭喜自己一下 欢迎大家访问我的店铺http://shop34362821.taobao.com/还有我的网站www.OurEDA.cnwww.Just430.cn...
用户88827 2008-06-06 19:39
Easy-MSP430 V1.1
 这就是V1.1的Easy430了 相对于之前的Easy430板子  我们增加了Nokia5110 LCD接口5个按键2个LED指示灯74HC595驱动的8段数码管而去掉了右侧的焊盘 这个板子同样提供...
用户88827 2008-03-15 10:25
EasyNET2103
EasyNET-2103是EasyNET系列开发板的第二款 其基本构成如下:核心 NXP ARM7 LPC2103(128KROM/32KRAM)网络 ENC28J60/HR911105A存储 SD/...
用户88827 2008-03-02 18:08
LPC2103和wiggler
最近刚刚回来EasyLPC2103http://auction1.taobao.com/auction/item_detail-0db1-40f6cd9461452ea2cd1b4e693fa2f5f...
用户88827 2007-12-09 09:09
终于把easynet弄完了
昨天有焊了一个完整的以太网板子 前一个还没焊完就被人给买走了 @@这个弄好了 测试了一个晚上的CS8900部分还是很稳定的 #/bin/sh`/bin/ping 192.168.10.252 -i 0...
我要评论
1
9
关闭 站长推荐上一条 /2 下一条