|
DSP28035驱动的ST7920液晶不能在液晶上显示(并口方式)
[复制链接]
各位大侠,你好! 我以C51的并口驱动代码位基础,将其移植到DSP28035上,都调试了一个星期,却仍然无法在显示屏上显示出我要的字符!在LCD的各个引脚上测试的高低电平也没有问题。另外对比度的两个引脚都已经设置为高电平(LCD中的引脚3与引脚18) 请各位大侠指正,万分感谢。
代码中函数如下: #define SELECT_INSTRUCTION_REG 0x0000//选择的是写指令寄存器 #define SELECT_DATA_REG 0x0002 //选择的是写数据寄存器
//片选引脚RS 使能EN 读写RW引脚等的宏 #define LCD_E_EN GpioDataRegs.AIOSET.bit.AIO2 = 1; #define LCD_E_DIS GpioDataRegs.AIOCLEAR.bit.AIO2 = 1;
#define LCD_RW_EN GpioDataRegs.AIOSET.bit.AIO4 = 1; #define LCD_RW_DIS GpioDataRegs.AIOCLEAR.bit.AIO4 = 1;
#define LCD_RS_EN GpioDataRegs.AIOSET.bit.AIO6 = 1; #define LCD_RS_DIS GpioDataRegs.AIOCLEAR.bit.AIO6 = 1;
#define LCD_TR_EN GpioDataRegs.GPBSET.bit.GPIO39 = 1; #define LCD_TR_DIS GpioDataRegs.GPBCLEAR.bit.GPIO39= 1;
#define LCD_BK_EN GpioDataRegs.GPASET.bit.GPIO21 = 1; #define LCD_BK_DIS GpioDataRegs.GPACLEAR.bit.GPIO21= 1;
#define LCD_RE_EN GpioDataRegs.GPASET.bit.GPIO20 = 1; #define LCD_RE_DIS GpioDataRegs.GPACLEAR.bit.GPIO20= 1;
//数据8个引脚的宏 #define LCDPIN_D0_SET GpioDataRegs.GPASET.bit.GPIO0 = 1; #define LCDPIN_D1_SET GpioDataRegs.GPASET.bit.GPIO1 = 1; #define LCDPIN_D2_SET GpioDataRegs.GPASET.bit.GPIO2 = 1; #define LCDPIN_D3_SET GpioDataRegs.GPASET.bit.GPIO3 = 1; #define LCDPIN_D4_SET GpioDataRegs.GPASET.bit.GPIO4 = 1; #define LCDPIN_D5_SET GpioDataRegs.GPASET.bit.GPIO5 = 1; #define LCDPIN_D6_SET GpioDataRegs.GPASET.bit.GPIO6 = 1; #define LCDPIN_D7_SET GpioDataRegs.GPASET.bit.GPIO7 = 1;
#define LCDPIN_D0_CLEAR GpioDataRegs.GPACLEAR.bit.GPIO0 = 1; #define LCDPIN_D1_CLEAR GpioDataRegs.GPACLEAR.bit.GPIO1 = 1; #define LCDPIN_D2_CLEAR GpioDataRegs.GPACLEAR.bit.GPIO2 = 1; #define LCDPIN_D3_CLEAR GpioDataRegs.GPACLEAR.bit.GPIO3 = 1; #define LCDPIN_D4_CLEAR GpioDataRegs.GPACLEAR.bit.GPIO4 = 1; #define LCDPIN_D5_CLEAR GpioDataRegs.GPACLEAR.bit.GPIO5 = 1; #define LCDPIN_D6_CLEAR GpioDataRegs.GPACLEAR.bit.GPIO6 = 1; #define LCDPIN_D7_CLEAR GpioDataRegs.GPACLEAR.bit.GPIO7 = 1;
//配置DSP上在LCD中用到的引脚 void SPI_Gpio_select(void) { EALLOW; SysCtrlRegs.WDCR = 0x0068;//禁止看门狗
GpioCtrlRegs.GPBMUX1.bit.GPIO39=0; //通用IO(LCD背光灯) GpioCtrlRegs.GPBDIR.bit.GPIO39 =1; //输出 GpioCtrlRegs.GPBPUD.bit.GPIO39 =0; //禁止上拉电阻
GpioCtrlRegs.GPAMUX2.bit.GPIO20=0; //通用IO(片选CS管脚) GpioCtrlRegs.GPADIR.bit.GPIO20 =1; //输出 GpioCtrlRegs.GPAPUD.bit.GPIO20 =0; //禁止上拉电阻
GpioCtrlRegs.GPAMUX2.bit.GPIO21=0; //数据管脚SPISIMO GpioCtrlRegs.GPADIR.bit.GPIO21 =1; //输出 GpioCtrlRegs.GPAPUD.bit.GPIO21 =0;
GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; GpioCtrlRegs.GPADIR.bit.GPIO1 = 1; GpioCtrlRegs.GPADIR.bit.GPIO2 = 1; GpioCtrlRegs.GPADIR.bit.GPIO3 = 1; GpioCtrlRegs.GPADIR.bit.GPIO4 = 1; GpioCtrlRegs.GPADIR.bit.GPIO5 = 1; GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; GpioCtrlRegs.GPADIR.bit.GPIO7 = 1;
EDIS; }
//延时 void F_delay(Uint16 D_time) { Uint16 i=0; for(i=0;i<D_time;i++); }
//写指令或者数据 void send_data(Uint16 D_Ctrl,Uint16 D_data) { Uint16 i=0,temp=0;
//#if PARALLEL_8_BIT_MODE//8位一起发送
//checkBF();//测试BF位是否忙
if(D_Ctrl == SELECT_INSTRUCTION_REG)//写指令到LCD { LCD_RS_DIS; } else if(D_Ctrl == SELECT_DATA_REG)//写数据到LCD { LCD_RS_EN; } LCD_RW_DIS; LCD_E_EN; F_delay(100);
if(D_data & 0x01){LCDPIN_D0_SET;}else{LCDPIN_D0_CLEAR;}; if(D_data & 0x02){LCDPIN_D1_SET;}else{LCDPIN_D1_CLEAR;}; if(D_data & 0x04){LCDPIN_D2_SET;}else{LCDPIN_D2_CLEAR;}; if(D_data & 0x08){LCDPIN_D3_SET;}else{LCDPIN_D3_CLEAR;}; if(D_data & 0x10){LCDPIN_D4_SET;}else{LCDPIN_D4_CLEAR;}; if(D_data & 0x20){LCDPIN_D5_SET;}else{LCDPIN_D5_CLEAR;}; if(D_data & 0x40){LCDPIN_D6_SET;}else{LCDPIN_D6_CLEAR;}; if(D_data & 0x80){LCDPIN_D7_SET;}else{LCDPIN_D7_CLEAR;};
LCD_E_DIS; F_delay(100); LCD_RW_EN; if(D_Ctrl == SELECT_INSTRUCTION_REG)//写指令到LCD { LCD_RS_EN; } else if(D_Ctrl == SELECT_DATA_REG)//写数据到LCD { LCD_RS_DIS; } F_delay(100); }
//LCD初始化 void LCD_Initial(void) {
LOG_printf(&trace,"LCD_Initial come here "); //复位操作:RST出现一个上升沿(RST = 1;RST = 0;RST = 1) GpioDataRegs.GPASET.bit.GPIO20 = 1; //延时 F_delay(10000); GpioDataRegs.GPACLEAR.bit.GPIO20 = 1; //延时 F_delay(10000); GpioDataRegs.GPASET.bit.GPIO20 = 1; //延时 F_delay(1000);
//显示状态开关 send_data(SELECT_INSTRUCTION_REG,0x0008); LOG_printf(&trace,"0x0008 "); F_delay(120); //功能设定 send_data(SELECT_INSTRUCTION_REG,0x0030); //功能设定,8位控制模式 LOG_printf(&trace,"0x0030 "); //延时 F_delay(120); //再次功能设定 send_data(SELECT_INSTRUCTION_REG,0x0030); //功能设定,8位控制模式 LOG_printf(&trace,"0x0030 "); //延时 F_delay(120); //显示开关控制(整体显示关,游标显示关,正常显示(游标位置没有反白)) send_data(SELECT_INSTRUCTION_REG,0x000C); LOG_printf(&trace,"0x000c "); //延时 F_delay(120); //清除显示 send_data(SELECT_INSTRUCTION_REG,0x0001); LOG_printf(&trace,"0x0001 "); //延时 F_delay(10000); //进入点设置(游标右移,DDRAM位地址加1,画面不移动) //串口中将此进入点设置给屏蔽掉了,待调试中再做决定 send_data(SELECT_INSTRUCTION_REG,0x06); LOG_printf(&trace,"0x0006 "); //延时 F_delay(120); //显示开关控制(开显示) send_data(SELECT_INSTRUCTION_REG,0x000C); LOG_printf(&trace,"0x000c "); F_delay(120);
//地址归位 send_data(SELECT_INSTRUCTION_REG,0x02); F_delay(120);
//设定DDRAM send_data(SELECT_INSTRUCTION_REG,0x80); F_delay(120);
}
//LCD任务 void LcdTask(void) { int i = 0;
GpioDataRegs.GPACLEAR.bit.GPIO21 = 1; //背光灯 g_StateCheck.bit.Start_Stage00 = 0; GpioDataRegs.GPBSET.bit.GPIO39 =1; SPI_Gpio_select(); //SPI管脚配置 LCD_Initial(); //LCD初始化 F_delay(10000);
for(;;) { send_data(SELECT_INSTRUCTION_REG,0x84);//设定显示地址为首行首列 send_data(SELECT_DATA_REG,0x34); send_data(SELECT_DATA_REG,0xD2); send_data(SELECT_DATA_REG,0xBA);//显示"液" send_data(SELECT_DATA_REG,0xBE); send_data(SELECT_DATA_REG,0xA6);//显示"晶" } }
|
|