/*
* main.c
*/
unsigned char tab[]={\"01234567\"};
#define uchar unsigned char
#define uint unsigned int
#define lcd_dir P1DIR //
#define lcd_out P1OUT //
#define RS_1 P2OUT |= BIT0 //RS至
#define RS_0 P2OUT &= ~BIT0 //RS置
#define RW_1 P2OUT |= BIT1 //RW置
#define RW_0 P2OUT &= ~BIT1
#define E_1 P2OUT |= BIT2
#define E_0 P2OUT &= ~BIT2
#define OUT P2DIR |= BIT0 + BIT1 + BIT2//写指令
void WriteInstrustion(uchar dictate)
{
OUT;
lcd_dir = 0xff;
_delay_cycles(5000);
E_0;
RS_0;
// P2.0,1,2输出
RW_0;
_delay_cycles(2);
E_1;
lcd_out = dictate;
_delay_cycles(1000);
E_0;
}
//写地址
void WriteAddress(uchar x)
{
WriteInstrustion(x|0x80);
}
//写数据
void WriteData(uchar y)
{
OUT;
lcd_dir = 0xff;
_delay_cycles(5000);
RS_1;
E_0;
RW_0;
_delay_cycles(2);
E_1;
lcd_out = y;
_delay_cycles(1000);
E_0;
RS_0;
}
//初始化
void Lcd_Init()
{
_delay_cycles(15000);
WriteInstrustion(0x38);
_delay_cycles(50);
WriteInstrustion(0x38);
WriteInstrustion(0x38);
WriteInstrustion(0x0c);
WriteInstrustion(0x06);
WriteInstrustion(0x01); //清屏幕指令,将以前的显示内容清除
}
//AD初始化程序:
//入口参数:无
//出口参数:无
}
//主函数
void main(void)
{
uint t=0;
WDTCTL=WDTPW+WDTHOLD;
Lcd_Init();
ADC10_Init();
WriteAddress(0x03);
WriteData('V');
WriteData('P');
WriteData('P');
WriteData(':');
while(1);
{
//
}