LCD1602_8 data

程序要写出自己的风格
******************************************************
**这是学习 msp430g2553 单片机时写的 1602 的程序**
**时间精确到us , 基本不出乱码**
**P1为数据输出端口**
**rs 接 p2.1**
**rw 接地**
**en 接 p2.0**
【LCD1602_8 data】******************************************************
#include
#include
#define rs_0 P2OUT&=~BIT1
#define rs_1 P2OUT|=BIT1
#define en_0 P2OUT&=~BIT0
#define en_1 P2OUT|=BIT0
char table_1[]={"SHOU BU NIAO L !"};
char table_2[]={"2012.8.02"};
unsigned int num;
unsigned int con_1,con_2;
void LCD1602_write_command(unsigned int com)
{
rs_0;
P1OUT=com;
__delay_cycles(500);
en_1;
__delay_cycles(500);
en_0;
}
void LCD1602_write_data(unsigned int dat)
{
rs_1;
P1OUT=dat;
__delay_cycles(500);
en_1;
__delay_cycles(500);
en_0;
}
void LCD1602_init()
{
LCD1602_write_command(0x38);//5*7点阵 , 双行显示
LCD1602_write_command(0x0c);//0x0f 有光标 , 
LCD1602_write_command(0x01);//清屏
LCD1602_write_command(0x06);//写入数据后 , 光标右移 , 显示屏不动
LCD1602_write_command(0x80);
}
void main ()
{
con_1=strlen(table_1);
con_2=strlen(table_2);

WDTCTL=WDTPW+WDTHOLD;

P1DIR =0XFF;
P2DIR=0XFF;

LCD1602_init();

for(num=0;num{
LCD1602_write_data(table_1[num]);
__delay_cycles(1000);
}

LCD1602_write_command(0x80+0x40);
for(num=0;num{
LCD1602_write_data(table_2[num]);
__delay_cycles(1000);
}

while(1);
}


    推荐阅读