访问手机版页面
你的位置:老古开发网 > MSP430驱动LCD显示 > 正文  
MSP430f149上LCD显示的程序
内容导读:

MSP430f149上LCD显示的程序【转载】#include<msp430x14x.h>

void Init_lcd(void);
void LCD_DataWrite(char Data);
void Lcd_InsWrite(char Instruction);
/******************显示时间*****************/
void main(void)
{
 char i;
 WDTCTL=WDTPW+WDTHOLD;
 Init_lcd();
 for(i=0;i<10;i++)
 {
 Lcd_InsWrite(0x84);         //第一行
 LCD_DataWrite(0xbb);        //  欢
 LCD_DataWrite(0xb6); 
 LCD_DataWrite(0xd3);       //迎
 LCD_DataWrite(0xad);        
 LCD_DataWrite(0xca);       //使
 LCD_DataWrite(0xb9);
 LCD_DataWrite(0xd3);       //用
 LCD_DataWrite(0xc3);
 
 Lcd_InsWrite(0x94);         //第2行
 LCD_DataWrite(0xce);        // 无
 LCD_DataWrite(0xde); 
 LCD_DataWrite(0xcf);       //线
 LCD_DataWrite(0xdf);        
 LCD_DataWrite(0xb3);       //抄
 LCD_DataWrite(0xad);
 LCD_DataWrite(0xb1);       //表
 LCD_DataWrite(0xed);        
 LCD_DataWrite(0xa3);       //!
 LCD_DataWrite(0xa1);
 Delay(5);
 }
Lcd_InsWrite(0x01);  //清除显示
Delay(100);
Lcd_InsWrite(0x01);  //清除显示
Delay(100); 
  Lcd_InsWrite(0x80);         //第一行
 LCD_DataWrite(0xb3);       //抄
 LCD_DataWrite(0xad);
 LCD_DataWrite(0xb1);       //表
 LCD_DataWrite(0xed);   
 LCD_DataWrite(0xc2);       //吗
 LCD_DataWrite(0xf0);
 LCD_DataWrite(0xa3);       //?
 LCD_DataWrite(0xbf);
 
 Lcd_InsWrite(0x90);         //第2行
 LCD_DataWrite(0xd0);        // 修
 LCD_DataWrite(0xde); 
 LCD_DataWrite(0xb8);       //改
 LCD_DataWrite(0xa6);        
 LCD_DataWrite(0xca);       //时
 LCD_DataWrite(0xb1);
 LCD_DataWrite(0xbc);       //间
 LCD_DataWrite(0xe4);        
 LCD_DataWrite(0xa3);       //?
 LCD_DataWrite(0xbf);
 } 
void Delay(int m)
{int i=0;
for(i=0;i<m;i++);
}
/************初始化LCD***********************/   
 void Init_lcd(void)
 {
   P4DIR =0XE0;          //P4.7,P4.6,P4.5 输出
   Lcd_InsWrite(0x30);
   Delay(400);
   Lcd_InsWrite(0x0f);  // 显示状态设定:整体显示,游标on,游标位置反白
   Delay(400);
   Lcd_InsWrite(0x01);  //清除显示
   Delay(400); 
       Lcd_InsWrite(0x06);  //游标向右移,AC自动加1
   Delay(400);
       Lcd_InsWrite(0x14);  //游标向右移
   Delay(400);
}
 /********************写指令****************************/
void Lcd_InsWrite(char Instruction)
{
  P5DIR=0XFF;
  P4OUT&=0x3f;        // RS=0  指令   // R/W=0  写
  P4OUT =BIT5;         //E=1   使能
  P5OUT=Instruction;   //功能设定
  Delay(3);
  P4OUT&=~BIT5;        //E=0:下降沿锁存数据
  P4OUT =BIT6+BIT7;   //RS=1,E/W=1
 
}
  
/****LCD_WRITE.C  显示文字*******************/
  
   void LCD_DataWrite(char Data)
  {
   P5DIR=0XFF;
   P4OUT =BIT7;   //RS=1  写数据
   P4OUT&=~BIT6;  //R/W=0   写
   P5OUT=Data;    //写数据
   P4OUT =BIT5;    //E=1  使能
   Delay(3);
   P4OUT&=~BIT5;  //E=0锁存
   P4OUT =BIT6+BIT7;   //RS=1,E/W=1
}

标签:
来源: 作者: 时间:2006/9/25 16:50:53
相关阅读
推荐阅读
阅读排行
最近更新
商品推荐