基于MSP430F449的LCD12864液晶屏 为什么不显示。 程序如下 50
#include"msp430x44x.h"#defineucharunsignedchar#defineuintunsignedint#defineRS1P2OUT|=...
#include "msp430x44x.h"
#define uchar unsigned char
#define uint unsigned int
#define RS1 P2OUT |=BIT0
#define RS0 P2OUT&=~BIT0
#define RW1 P2OUT |=BIT1
#define RW0 P2OUT&=~BIT1
#define EN1 P2OUT |=BIT2
#define EN0 P2OUT&=~BIT2
#define data P1DIR
float temp;
uchar table2[]="设定温度:60℃";
uchar table3[]="当前温度: . ℃";
void delay(uint n)
{
while(n--);
}
void busy()
{
EN1;//en=1
RS0; //rs=0
RW1;//rw=1
while(P1IN & 0x80)
EN0;//en=0
}
void write_cmd(uchar cmd)
{
busy();
P1DIR=0xff;
EN1;//en=1
RS0;//rs=0
RW0;//rw=0
P1OUT = cmd;
delay(50);
EN0;//en=0
}
void write_Data(uchar dat)
{
busy();
P1DIR=0xff;
EN1;//en=1
RS1;//rs=1
RW0;//rw=0
P1OUT=dat;
delay(50);
EN0;//en=0
}
void Lcd_CSH(void)
{
delay(4000);
write_cmd(0x30);
delay(100);
write_cmd(0x02);
delay(100);
write_cmd(0x0c);
delay(100);
write_cmd(0x01);
delay(10000);
write_cmd(0x06);
}
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
uchar num;
P1DIR=0xff;
P2DIR |= BIT0+BIT1+BIT2;
Lcd_CSH();//初始化液晶
while (1)
{
write_cmd(0x80);
for(num=0;num<12;num++)
{
write_Data(table2[num]);
}
write_cmd(0x90);
for(num=0;num<14;num++)
{
write_Data(table3[num]);
}
}
} 展开
#define uchar unsigned char
#define uint unsigned int
#define RS1 P2OUT |=BIT0
#define RS0 P2OUT&=~BIT0
#define RW1 P2OUT |=BIT1
#define RW0 P2OUT&=~BIT1
#define EN1 P2OUT |=BIT2
#define EN0 P2OUT&=~BIT2
#define data P1DIR
float temp;
uchar table2[]="设定温度:60℃";
uchar table3[]="当前温度: . ℃";
void delay(uint n)
{
while(n--);
}
void busy()
{
EN1;//en=1
RS0; //rs=0
RW1;//rw=1
while(P1IN & 0x80)
EN0;//en=0
}
void write_cmd(uchar cmd)
{
busy();
P1DIR=0xff;
EN1;//en=1
RS0;//rs=0
RW0;//rw=0
P1OUT = cmd;
delay(50);
EN0;//en=0
}
void write_Data(uchar dat)
{
busy();
P1DIR=0xff;
EN1;//en=1
RS1;//rs=1
RW0;//rw=0
P1OUT=dat;
delay(50);
EN0;//en=0
}
void Lcd_CSH(void)
{
delay(4000);
write_cmd(0x30);
delay(100);
write_cmd(0x02);
delay(100);
write_cmd(0x0c);
delay(100);
write_cmd(0x01);
delay(10000);
write_cmd(0x06);
}
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
uchar num;
P1DIR=0xff;
P2DIR |= BIT0+BIT1+BIT2;
Lcd_CSH();//初始化液晶
while (1)
{
write_cmd(0x80);
for(num=0;num<12;num++)
{
write_Data(table2[num]);
}
write_cmd(0x90);
for(num=0;num<14;num++)
{
write_Data(table3[num]);
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询