将51单片机lcd显示改写成下面28035的,请大家看看有什么问题,屏幕没有任何显示。
#include "DSP28x_Project.h"
#define uint16 unsigned char
#define uint32 unsigned int
#define RS GpioDataRegs.GPADAT.bit.GPIO8
#define RW GpioDataRegs.GPADAT.bit.GPIO9
#define E GpioDataRegs.GPADAT.bit.GPIO10
#define PSB GpioDataRegs.GPADAT.bit.GPIO11
#define BF GpioDataRegs.GPADAT.bit.GPIO7
void init_gpio(void);
void init_12864(void); //12864初始化
void write_order12864(uint16 order); //向12864中写入命令
void write_data12864(uint16 shuju); //向12864中写入数据
uint16 Busy_12864(void); //12864忙信号检测
void write_address(uint16 y,uint16 x); //数据显示位置
void static1(void);
uint16 const a[]={"你好!"};
void main(void)
{
InitSysCtrl();
DINT;
InitPieCtrl();
IFR=0x0000;
IER=0x0000;
InitPieVectTable();
init_gpio();
init_12864();
while(1)
{
static1();
}
}
void init_gpio(void)
{
EALLOW;
GpioCtrlRegs.GPAMUX1.all=0x00000000;
GpioCtrlRegs.GPAMUX2.all=0x00000000;
GpioCtrlRegs.GPAPUD.all=0xffffffff;
GpioCtrlRegs.GPADIR.all=0x0000ffff;
EDIS;
GpioDataRegs.GPADAT.all=0x00000000;
}
void init_12864(void)
{
DELAY_US(2000); //26us
PSB=1;
write_order12864(0x30); //8位数据,基本指令操作
DELAY_US(8);
write_order12864(0x30); //8位数据,基本指令操作
DELAY_US(2);
write_order12864(0x0c); //数据整体显示,游标不显示
DELAY_US(8);
write_order12864(0x06); //游标移动方向
DELAY_US(8);
write_order12864(0x01); //清屏
DELAY_US(80);
}
void write_order12864(uint16 order) //写命令
{
while(Busy_12864()==1);
RS=0;
RW=0;
E=0;
DELAY_US(2);
E=1;
DELAY_US(8);
GpioDataRegs.GPADAT.all=(order&0x00ff)|GpioDataRegs.GPADAT.all;
DELAY_US(2);
E=0;
DELAY_US(2);
}
void write_data12864(uint16 shuju) //写数据
{
while(Busy_12864()==1);
RS=1;
RW=0;
E=0;
DELAY_US(2);
E=1;
DELAY_US(8);
GpioDataRegs.GPADAT.all=(shuju&0x00ff)|GpioDataRegs.GPADAT.all;
DELAY_US(2);
E=0;
DELAY_US(2);
}
uint16 Busy_12864(void) //忙信号检测
{
EALLOW;
GpioCtrlRegs.GPADIR.bit.GPIO7=0;
EDIS;
uint16 jiance=0;
RS=0;
RW=1;
E=1;
DELAY_US(2);
jiance+=BF;
DELAY_US(2);
E=0;
DELAY_US(2);
EALLOW;
GpioCtrlRegs.GPADIR.bit.GPIO7=1;
EDIS;
return jiance;
}
void write_address(uint16 y,uint16 x) //数据显示位置
{
switch(y)
{
case 1: write_order12864(0x0080|x);
break;
case 2: write_order12864(0x0090|x);
break;
case 3: write_order12864(0x0088|x);
break;
case 4: write_order12864(0x0098|x);
break;
}
}
void static1(void)
{
write_order12864(0x01); //清屏
DELAY_US(8);
uint16 i=0;
write_address(2,1);
DELAY_US(8);
while(a!=' ')
{
write_data12864(a);
i++;
DELAY_US(20);
}
}
此帖出自
小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>