|
本帖最后由 xutiemu 于 2013-1-10 00:36 编辑
(驱动芯片ST7920带字库)
关于这个问题,我始终得到的是两种结果:
1,不能,我在这个论坛上至少看到不下十个帖子谈到这个问题,至少不下100人说不能。
2,能。我从这个论坛上我找到一段代码支持spi读LCd12864的忙标志和GDRam数据。代码我我也贴出来。
/****************************************Copyright (c)****************************************************
** 重庆大学电气工程学院
**
**
**
**--------------File Info---------------------------------------------------------------------------------
** File Name: LCD12864.c
** Last modified Date: 2009/07/26
** Last Version: V1.10
** Description: LCD QY12864HZ1(st7920驱动芯片)在LM3S615上串行通信的驱动程序
**
**--------------------------------------------------------------------------------------------------------
** Created By: 张煜欣
** Created date: 2009/07/26
** Version: V1.00
** Descriptions:
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Description:
**
*********************************************************************************************************/
#include "Config.H"
/*********************************************************************************************************
** Function name: delayNuS
** Descriptions: 延时N个微秒
** input parameters: iTime: 延时时间
** output parameters: 无
** Returned value: 无
*********************************************************************************************************/
void delayNuS (int32 iTime)
{
iTime = SysCtlClockGet() * iTime / 2000000; /* 根据系统时钟速率确定延时 */
while (--iTime != 0);
}
/*********************************************************************************************************
** Function name: LCD_ByteWrite
** Descriptions: 向SPI 总线写入1 个字节的数据。
** input parameters: cDat:要写入的数据
** output parameters: 无
** Returned value: 无
*********************************************************************************************************/
void LCD_ByteWrite (int8 cDat)
{
int8 cT = 8;
GPIODirModeSet(LCD_PORT, LCD_DIO, GPIO_DIR_MODE_OUT); /* 设置DIO端口为输出模式 */
/*
* 循环写一个字节的数据
*/
do {
GPIOPinWrite(LCD_PORT, LCD_CLK, 0x00);//时钟控制信号
delayNuS(5); // 延时5us
if((cDat & 0x80) == 0x80) {
GPIOPinWrite(LCD_PORT, LCD_DIO, 0xff);
} else {
GPIOPinWrite(LCD_PORT, LCD_DIO, 0x00);
}
cDat <<= 1;
GPIOPinWrite(LCD_PORT, LCD_CLK, 0xff);//时钟控制信号
delayNuS(5); // 延时5us
} while (--cT != 0);
}
/*********************************************************************************************************
** Function name: LCD_ByteRead
** Descriptions: 从SPI 总线读取1 个字节的数据。
** input parameters: 无
** output parameters: 无
** Returned value: 读取到的数据
*********************************************************************************************************/
uint8 LCD_ByteRead (void)
{
uint8 i,temp1,temp2;
temp1 = 0;
temp2 = 0;
GPIODirModeSet(LCD_PORT, LCD_DIO, GPIO_DIR_MODE_IN); /* 设置DIO端口为输入模式 */
for(i=0;i<8;i++)
{
temp1=temp1<<1;
GPIOPinWrite(LCD_PORT, LCD_CLK, 0x00);//时钟控制信号
delayNuS(5);
GPIOPinWrite(LCD_PORT, LCD_CLK, 0xFF);
delayNuS(5);
GPIOPinWrite(LCD_PORT, LCD_CLK, 0x00);
delayNuS(5);
//SCK = 0;
//SCK = 1;
//SCK = 0;
if(GPIOPinRead(LCD_PORT, LCD_DIO))
temp1++;
}
for(i=0;i<8;i++)
{
temp2=temp2<<1;
GPIOPinWrite(LCD_PORT, LCD_CLK, 0x00);//时钟控制信号
delayNuS(5);
GPIOPinWrite(LCD_PORT, LCD_CLK, 0xFF);
delayNuS(5);
GPIOPinWrite(LCD_PORT, LCD_CLK, 0x00);
delayNuS(5);
//SCK = 0;
//SCK = 1;
//SCK = 0;
if(GPIOPinRead(LCD_PORT, LCD_DIO))
temp2++;
}
GPIOPinTypeGPIOOutput( LCD_PORT , LCD_DIO );
return ((0xf0&temp1)+(0x0f&temp2));
}
/******************************************************************************************
* 函数名称 :CheckBusy
* 功能描述 :
* 参数 : 参数名称: 输入/输出? 类型 描述
*
* 返回值 :
* 作者 :
* 创建日期 :2006-12-19
* 全局变量 :
* 全局静态变量:
* 局部静态变量:
*----------------------------------------修改历史------------------------------------------
* 当前版本 : 修改人: 修改日期:
* 修改说明 :
******************************************************************************************/
void CheckBusy(void)
{
do
{
LCD_ByteWrite(0xFC); //11111,RW(1),RS(0),0
}while(0x80&LCD_ByteRead()); //BF(.7)=1 Busy
}
-=========================================================================================》》》》》
还有从网上无意中看到郭天祥关于这个问题的代码,他同样给出了串行下读数据的例子,(附上文本地址GTXlcd12864串行驱动)我照着这两个版本移植了代码,发现读出的忙标志始终是 1。且读出的GDram的值始终是0xff。
我想说不可以的答案的可行性可能有一千种也说不定,比如代码有这样的那样的问题,未必真读不出来。但一旦有人读出来就说明真的能读出来。排除有的液晶支持,有的液晶不支持这个微小的可能性
代码出问题的可能性还是最大的。可是问题究竟出来哪里呢?都快一点钟了,我纠结的毫无睡意!真理在哪里啊?
这是我的代码,虽然是老问题,可是还是不能很好的解决,好没有成就感啊。
uint8 lcd_rdByte(void)
{
uint8 temp=0,i,temp1=0;
DATAIN;//将sid设置为输入
CESET;
NOP();
CECLR;
NOP();
CESET;
SCKCLR;
for(i=0;i<8;i++)
{
temp<<=1;
SCKSET;
if(PIN)
{temp|=0x01;}
SCKCLR;
}
temp&=0xf0;
for(i=0;i<8;i++)
{
temp1<<=1;
SCKSET;
if(PIN)
{temp1|=0x01;}
SCKCLR;
}
temp1&=0xf0;
temp=temp|(temp1>>4);
CECLR;
DATAOUT;
return temp;
}
void check_busy(void)
{ uint8 temp=0xff;
do{
lcd_wrByte(0xfc);//11111,rw 1,rs 0 ,0
temp=lcd_rdByte();
temp=temp&0x80;
} while(temp);
}
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!
|