|
请问有哪位大神能帮我看看这个程序么。1602显示0123,接口没问题的,就是显示不出来。
#include "msp430.h" //引用头文件
#include "msp430f5438.h"
/***************宏定义***************/
#define uchar unsigned char
#define uint unsigned int
#define RS_H P2OUT|= BIT1; //RS=P2.1
#define RS_L P2OUT&=~BIT1;
#define RW_H P2OUT|= BIT2; //RW=P2.2
#define RW_L P2OUT&=~BIT2;
#define EN_H P2OUT|= BIT3; //EN=P2.3
#define EN_L P2OUT&=~BIT3;
void delay(long unsigned int time)
{
while(time--); //延时子函数
}
void writeCmd(unsigned char wdata) //写命令
{
delay(100);
RS_L;
RW_L;
P1OUT = wdata;
EN_H;
delay(100);
EN_L;
}
void writeData(unsigned char wdata) //写数据
{
delay(100);
RS_H;
RW_L;
P1OUT = wdata;
EN_H;
delay(100);
EN_L;
}
void LCD_init(void)
{
delay(1000);
writeCmd(0x38); //设置16X2显示,5X7点阵,8位数据接口
delay(500);
writeCmd(0x01); //显示清屏
//writeCmd(0x0c); //开显示,关闭光标,当然光标也就不能显示了
//writeCmd(0x0e); //开显示,显示光标,但是光标不闪烁
writeCmd(0x0f); //开显示,显示光标,光标闪烁
writeCmd(0x06); //写字符时整体不移动
}
int main(void)
{
WDTCTL=WDTPW+WDTHOLD;
while(1)
{
P1DIR =0xff;
P2DIR =0x0e; //BIT1+BIT2+BIT3
LCD_init();
writeCmd(0x80);
writeData(0x30+0);
writeData(0x30+1);
writeData(0x30+2);
writeData(0x30+3);
while(1);
}
}
|
|