LCD的D0-D7接DSP的GPIOA0-GPIOA7;CS(GPIOB0)、SID(GPIOB1)、CLK(GPIOB2)、PSB(GPIOB3)、RST(GPIOB4),程序是看到别人的单片机程序,移植过来的,程序见附件,这里也贴出来,如下:
GPIO配置程序:
#include "DSP28_Device.h"
void InitGpio(void)
{
EALLOW;
GpioMuxRegs.GPAMUX.all=0x00;
GpioMuxRegs.GPBMUX.bit.PWM10_GPIOB3=0;
GpioMuxRegs.GPBMUX.bit.PWM10_GPIOB3=0;
GpioMuxRegs.GPADIR.all=0xFF;
GpioMuxRegs.GPBDIR.bit.GPIOB3=1;
GpioMuxRegs.GPBDIR.bit.GPIOB3=1;
EDIS;
}
主程序:
#include "DSP28_Device.h"
#define RS_CS0 GpioDataRegs.GPBCLEAR.bit.GPIOB0=1 //片选信号RS 模组片选端,高电平有效
#define RS_CS1 GpioDataRegs.GPBSET.bit.GPIOB0=1
#define RW_SID0 GpioDataRegs.GPBCLEAR.bit.GPIOB1=1 //串行数据输入端
#define RW_SID1 GpioDataRegs.GPBSET.bit.GPIOB1=1
#define EN_CLK0 GpioDataRegs.GPBCLEAR.bit.GPIOB2=1 //串行同步时钟:上升沿时读取SID数据
#define EN_CLK1 GpioDataRegs.GPBSET.bit.GPIOB2=1
#define PSB GpioDataRegs.GPBDAT.bit.GPIOB3 //H:8位或4位并口方式;L:串口方式
#define RST GpioDataRegs.GPBDAT.bit.GPIOB4 //复位端,低电平有效
#define CSOUT EALLOW;GpioMuxRegs.GPBDIR.bit.GPIOB0 = 1;EDIS//片选信号输出
#define SIDOUT EALLOW;GpioMuxRegs.GPBDIR.bit.GPIOB1 = 1;EDIS//数据信号输出
#define CLKOUT EALLOW;GpioMuxRegs.GPBDIR.bit.GPIOB2 = 1;EDIS//时钟信号输出
#define RSTOUT EALLOW;GpioMuxRegs.GPBDIR.bit.GPIOB4 = 1;EDIS//复位信号输出
#define CSIN EALLOW;GpioMuxRegs.GPBDIR.bit.GPIOB0 = 0;EDIS//片选信号输入
#define SIDIN EALLOW;GpioMuxRegs.GPBDIR.bit.GPIOB1 = 0;EDIS//数据信号输入
#define CLKIN EALLOW;GpioMuxRegs.GPBDIR.bit.GPIOB2 = 0;EDIS//时钟信号输入
#define comm 0 //指令0
#define data 1 //数据1
#define x1 0x80
#define x2 0x88
#define y 0x80
#define uchar unsigned char /*宏定义*/
#define uint unsigned int
void delayns(unsigned int ns);
void delayus(unsigned int us);
void WriteLcd(unsigned char st);
void DataComWrite(uchar data_comm,uchar text);
void ChinDisp(uchar *chin);
void clcscreen();
void InitLcd();
void LatDisp(uchar dat1,uchar dat2);
void ImgDisp(uchar *imge);
void ChkBusy();
/*-- 调入了一幅图像:宽度x高度=128x32 可以使用点阵图形生成器产生数据--*/
uchar tab1[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFA,0xAB,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFE,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xEF,0xFF,0xBF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xEF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xBF,0xFF,0xFB,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFE,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xC0,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xF0,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFC,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xC1,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0x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F,0xFF,0xFD,0xFF,0xFF,0xFF,0xFF,0xFE,0xBF,0x80,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xBF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x83,0xFF,0xFF,0xFF,0xFF,0xF8,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x3F,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x0F,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x03,0xFF,0xFF,0xFF,0x60,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0x7F,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xDF,0xFF,0xFD,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xF7,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFD,0xFF,0xF7,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0x7F,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xD5,0x5F,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
uchar tab2[]={
"尊敬的用户: "
"们的产品! 希望您"
" 欢迎您使用我"
"使用淇? "
};
/*----------------- 延时函数---------------------*/
void delayns(unsigned int tns)
{
while(tns>0) tns--;
}
void delayus(unsigned int tus)
{ int i,j;
for(j=0;j<tus;j++)
for(i=0;i<100;i++);
}
/*写数据到GPIOA0-GPIOA7*/
void WriteLcd(unsigned char str)
{
GpioDataRegs.GPADAT.all=str&0xFF;
}
/*----------------LCD数据指令写函数---------------------*/
void DataComWrite(uchar data_comm,uchar content)
{
RS_CS0;
RW_SID0;
if(data_comm)
{
RS_CS1;
RW_SID0;
}
else
{
RS_CS0;
RW_SID0;
}
delayns(20);
WriteLcd(content); //comm
EN_CLK1;
delayus(70);
EN_CLK0;
delayus(40);
}
/*----------------显示汉字程序-----------------*/
void ChinDisp(uchar *chn)
{
uchar i,j;
DataComWrite(comm,0x30);
delayus(100);
DataComWrite(comm,0x80);
for (j=0;j<4;j++)
{
for (i=0;i<16;i++)
{
DataComWrite(data,chn[j*16+i]);
delayus(10);
}
}
}
/*----------------LCD清屏函数-----------------*/
void clcscreen()
{
delayus(200);
DataComWrite(comm,0x30);
delayus(200);
DataComWrite(comm,0x01);
delayus(200);
}
void ChkBusy()
{
DataComWrite(data,0xff);
RS_CS0;
RW_SID1;
EN_CLK1;
while(GpioDataRegs.GPADAT.bit.GPIOA7==1);
EN_CLK0;
}
/*----------------LCD初始化函数-----------------*/
void InitLcd()
{ CSOUT;
SIDOUT;
CLKOUT;
RSTOUT;
PSB=1;
RST=0;
delayus(1000);
RST=1;
delayus(50000);
DataComWrite(comm,0x30);//30---基本指令动作
delayus(500);
DataComWrite(comm,0x30);
delayus(200);
DataComWrite(comm,0x0c); //开显示,关游标
delayus(500);
DataComWrite(comm,0x01); // 清屏,地址指针指向00H
delayus(20000);
DataComWrite(comm,0x06); //光标的移动方向
delayus(20000);
}
/*----------------LCD显示图像函数-----------------*/
void ImgDisp(uchar *img)
{
int i;
int j;
for(j=0;j<32;j++)
{
for(i=0;i<8;i++)
{
DataComWrite(comm,0x34);
delayus(200);
DataComWrite(comm,y+j);
delayus(200);
DataComWrite(comm,x1+i);
delayus(200);
DataComWrite(comm,0x30);
delayus(200);
DataComWrite(data,img[j*16+i*2]);
delayus(200);
DataComWrite(data,img[j*16+i*2+1]);
delayus(200);
}
}
for(j=32;j<64;j++)
{
for(i=0;i<8;i++)
{
DataComWrite(comm,0x34);
delayus(200);
DataComWrite(comm,y+j-32);
delayus(200);
DataComWrite(comm,x2+i);
delayus(200);
DataComWrite(comm,0x30);
delayus(200);
DataComWrite(data,img[j*16+i*2]);
delayus(200);
DataComWrite(data,img[j*16+i*2+1]);
delayus(200);
}
}
DataComWrite(comm,0x36);
}
/*----------------显示点阵-----------------*/
void LatDisp(uchar data1,uchar data2)
{
uchar i,j,k,x;
x=x1;
for(k=0;k<2;k++)
{
for(j=0;j<16;j++)
{
for(i=0;i<8;i++)
{
DataComWrite(comm,0x34);
delayus(200);
DataComWrite(comm,y+j*2);
delayus(200);
DataComWrite(comm,x+i);
delayus(200);
DataComWrite(comm,0x30);
delayus(200);
DataComWrite(data,data1);
delayus(200);
DataComWrite(data,data1);
delayus(200);
}
for(i=0;i<8;i++)
{
DataComWrite(comm,0x34);
delayus(200);
DataComWrite(comm,y+j*2+1);
delayus(200);
DataComWrite(comm,x+i);
delayus(200);
DataComWrite(comm,0x30);
delayus(200);
DataComWrite(data,data2);
delayus(200);
DataComWrite(data,data2);
delayus(200);
}
}
x=x2;
}
DataComWrite(comm,0x36);
}
/*----------------主函数-----------------*/
void main(void)
{
/*初始化系统*/
InitSysCtrl();
DINT;
IER = 0x0000;
IFR = 0x0000;
/*初始化PIE*/
InitPieCtrl();
/*初始化PIE中断矢量表*/
InitPieVectTable();
InitGpio();
InitLcd(); //初始化LCD
while(1)
{
clcscreen(); //清屏
delayus(5000); //延时
ImgDisp(tab1); //显示图像1,HELLODSP的**
delayus(5000);
LatDisp(0x00,0x00); //清屏,作用等同于clrram();
ChinDisp(tab2); //显示汉字"尊敬的用户,感谢您使用我们的产品,希望您使用愉快!"
delayus(5000);
}
}
就这样了,感觉写的这个和人家单片机的程序是一样的了,为什么还是不能显示啊,有说DSP是一个高速器件,LCD是慢显示器件,我加了很多延时,但是还是不行哒,大神们,求助!!!!LCD1206的驱动程序也一样,,弄死不显示,一起放到附件,各位高手,帮忙看看吧,如果好了,可以发送到我的邮jonymayor@163.com
|