你好,我用28069驱动1602程序没有反应,程序是从51程序改过来的,中间使用了3.3V-5V电平转换芯片,谢谢。
#include "DSP28x_Project.h"
#define Uchar unsigned char
#define Uint1616 unsigned int
#define Uint1632 unsigned long
#define RS GpioDataRegs.GPADAT.bit.GPIO8
#define RW GpioDataRegs.GPADAT.bit.GPIO9
#define E GpioDataRegs.GPADAT.bit.GPIO10
#define BF GpioDataRegs.GPADAT.bit.GPIO7
void init_1602(void); //初始化液晶
void zhongduan(void); //开启中断
void write_order(Uchar order); //指令输入
void write_data(Uchar shuju); //数据输入
Uchar Busy(void);
Uchar a1[]={"BEIJING TIME"};
Uchar a2[]={"19:39:00"};
void main(void)
{
InitSysCtrl();
DINT;
InitPieCtrl();
InitCpuTimers();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
GpioCtrlRegs.GPAPUD.all=0; // Enable pullup on
GpioCtrlRegs.GPAMUX1.all=0;
GpioCtrlRegs.GPADIR.all=0xffffffff;
EDIS;
char k;
init_1602();
DELAY_US(200*50);
write_order(0x0c);
write_order(0x01);
DELAY_US(200*25);
write_order(0x03|0x80);
k=0;
while(a1[k]!='\0')
{
write_data(a1[k]);
k++;
DELAY_US(30*200);
}
write_order(0x43|0x80);
k=0;
while(a2[k]!='\0')
{
write_data(a2[k]);
k++;
DELAY_US(30*200);
}
for(k=0;k<10;k++)
DELAY_US(3000*200);
}
void init_1602(void)
{
DELAY_US(200*75); //延时15ms,首次写指令时应给LCD一段较长的反应时间
write_order(0x38); //显示模式设置:16×2显示,5×7点阵,8位数据接口
DELAY_US(200*25); //延时5ms
write_order(0x38);
DELAY_US(200*25);
write_order(0x38);
DELAY_US(200*25);
write_order(0x0f); //显示模式设置:显示开,有光标,光标闪烁
DELAY_US(200*25);
write_order(0x06); //显示模式设置:光标右移,字符不移
DELAY_US(200*25);
write_order(0x01); //清屏幕指令,将以前的显示内容清除
DELAY_US(200*25);
}
void write_order(Uchar order) //指令写入
{
while(Busy()==1); //如果忙就等待
RS=0;
RW=0;
DELAY_US(1);
E=0;
DELAY_US(2);
GpioDataRegs.GPADAT.all=order|0xffffff00;
DELAY_US(4);
E=1;
DELAY_US(4);
E=0;
}
void write_data(Uchar shuju) //写入数据
{
while(Busy()==1); //如果忙就等待
RS=1;
RW=0;
DELAY_US(1);
E=0;
DELAY_US(2);
GpioDataRegs.GPADAT.all=shuju|0xffffff00;
DELAY_US(4);
E=1;
DELAY_US(4);
E=0;
}
unsigned char Busy(void)
{
Uchar jiance;
RS=0; //根据规定,RS为低电平,RW为高电平时,可以读状态
RW=1;
DELAY_US(1);
E=1; //E=1,才允许读写
DELAY_US(2);
GpioCtrlRegs.GPADIR.bit.GPIO7=0;
jiance=BF&0x01; //将忙碌标志电平赋给result
GpioCtrlRegs.GPADIR.bit.GPIO7=1;
DELAY_US(2);
E=0;
DELAY_US(2);
return jiance;
}
|