#ifndef __LCD1602_H__
#define __LCD1602_H__
#include "msp430g2553.h"
#include "delay.h"
#define lcden_out P1DIR|=BIT2
#define lcden_in P1DIR&=~BIT2
#define lcden_h P1OUT|=BIT2
#define lcden_l P1OUT&=~BIT2
#define rw_out P1DIR|=BIT1
#define rw_in P1DIR&=~BIT1
#define rw_h P1OUT|=BIT1
#define rw_l P1OUT&=~BIT1
#define rs_out P1DIR|=BIT0
#define rs_in P1DIR&=~BIT0
#define rs_h P1OUT|=BIT0
#define rs_l P1OUT&=~BIT0
#define data P2OUT
void write_com(uchar com)
{
lcden_out;
rs_out;
rw_out;
P2DIR=0XFF;
rs_l;
rw_l;
lcden_l;
data=com;
delay(1);
lcden_h;
delay(1);
lcden_l;
}
void write_date(uchar date)
{
lcden_out;
rs_out;
P2DIR=0XFF;
rs_h;
rw_l;
lcden_l;
data=date;
delay(1);
lcden_h;
delay(1);
lcden_l;
}
void display_string(uchar *p,uchar com)
{
uchar i;
write_com(com);
for(i=0;i<16;i++)
{
write_date(p);
}
}
void init_lcd()
{
lcden_out;
lcden_l;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
display_string(" welcome ",0x80);
display_string("san xia xue yuan",0xc0);
}
#endif |