MSP430f149上LCD显示的程序【转载】
2009-10-12 11:28
190 查看
#i nclude<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
}
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
}
相关文章推荐
- 【Tiny6410 And Linux】—(6.2)—LCD 驱动测试程序(BMP 显示位图)——原理
- 【转载】Compact Framework程序的全屏显示
- Linux设备驱动之LCD显示摄像图像之二编写V4l2程序
- C#窗体内嵌外部程序(cmd.exe)的显示【转载】
- 单片机练习 - 带中文字库12864LCD显示程序
- (转载)在程序中显示位图
- C#窗体内嵌外部程序(cmd.exe)的显示(转载)
- lcd显示bmp图片程序
- 转载:LCD显示原理及应用
- 基于s3c2440 lcd framebuffer 320x240 驱动 测试 显示 320x240 16bpp bmp 图片测试程序
- NETC程序:GB2312汉字编码和C程序LCD显示实现
- 【Tiny6410 And Linux】—(6.2)—LCD 驱动测试程序(BMP 显示位图)——代码
- 转载:在C程序中显示汉字
- ARM9(S3C2440)的LCD显示——程序实例讲解
- 2440裸机程序——LCD图片显示实验
- 在μPD78F0485单片机实验盒上编写程序实现在LCD上显示日历功能
- iOS程序启动的时候隐藏状态栏,启动完成之后显示状态栏
- [转载]Visual Studio .NET 无法创建或打开应用程序。问题很可能是因为本地WEB本地服务器上没有安装所需的组件。请运行Visual Studio .NET安装程序并添加WEB开发组件 收藏
- 用VC++实现Console程序显示彩色文本
- Android程序在各个分辨率设备上全屏显示