打印

请教!STM32 FSMC读 HX8347 的 GRAM ,怎么用力都读不对。

[复制链接]
5095|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
harvest000|  楼主 | 2010-7-24 19:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1、TFT正常显示。
2、STM32 FSMC 读 HX8347 的 GRAM错误,读到的第一个数是0x00fc,第二个数是0x0000。
3、读 HX8347 的其它寄存器都正确。
请前辈、大侠、掌门、教主、帮主、方丈、师太、护_法、路人甲、路人乙指点。

(库函数3.0)
typedef struct
{
  volatile unsigned short int LCD_REG;
  volatile unsigned short int LCD_RAM;
} LCD_TypeDef;

/* LCD is connected to the FSMC_Bank1_NOR/SRAM4 and NE4 is used as ship select signal */
#define LCD_BASE    ((unsigned int)(0x60000000 | 0x0C000000))
#define LCD         ((LCD_TypeDef *) LCD_BASE)

TFTConfig(void)
{
GPIO_InitTypeDef GPIO_InitStructure;

FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;

// Enable FSMC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD |RCC_APB2Periph_GPIOE |RCC_APB2Periph_GPIOF |RCC_APB2Periph_GPIOG |RCC_APB2Periph_AFIO,ENABLE);

// PD.00(D2), PD.01(D3), PD.04(NOE), PD.05(NWE), PD.08(D13),
// PD.09(D14),PD.10(D15), PD.14(D0), PD.15(D1)
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_0 |GPIO_Pin_1 |GPIO_Pin_4 |GPIO_Pin_5 |GPIO_Pin_8 |GPIO_Pin_9 |GPIO_Pin_10 |GPIO_Pin_14 |GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);

// PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8),
// PE.12(D9), PE.13(D10), PE.14(D11), PE.15(D12)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 |GPIO_Pin_8 |GPIO_Pin_9 |GPIO_Pin_10 |GPIO_Pin_11 |GPIO_Pin_12 |GPIO_Pin_13 |GPIO_Pin_14 |GPIO_Pin_15;
GPIO_Init(GPIOE, &GPIO_InitStructure);

// PF.00(A0 (RS)) as alternate function push pull
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOF, &GPIO_InitStructure);

// PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_Init(GPIOG, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOG, &GPIO_InitStructure);

p.FSMC_AddressSetupTime = 0;
p.FSMC_AddressHoldTime = 0;
p.FSMC_DataSetupTime = 2;
p.FSMC_BusTurnAroundDuration = 0;
p.FSMC_CLKDivision = 0;
p.FSMC_DataLatency = 0;
p.FSMC_AccessMode = FSMC_AccessMode_A;

FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;

FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);   

// BANK 4 (of NOR/SRAM Bank 1~4) is enabled
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);

FDelay10000X(4);

LCD_RST_1;
FDelay10000X(1);
LCD_RST_0;
FDelay10000X(2);
LCD_RST_1;
FDelay10000X(4);

LCD_WriteReg(0x0046,0x0095);
LCD_WriteReg(0x0047,0x0051);
LCD_WriteReg(0x0048,0x0000);
LCD_WriteReg(0x0049,0x0036);
LCD_WriteReg(0x004A,0x0011);
LCD_WriteReg(0x004B,0x0066);
LCD_WriteReg(0x004C,0x0014);
LCD_WriteReg(0x004D,0x0077);
LCD_WriteReg(0x004E,0x0013);
LCD_WriteReg(0x004F,0x004C);
LCD_WriteReg(0x0050,0x0046);
LCD_WriteReg(0x0051,0x0046);

//240x320 window setting
LCD_WriteReg(0x0002,0x0000);   // Column address start2   
LCD_WriteReg(0x0003,0x0000);   // Column address start1   
LCD_WriteReg(0x0004,0x0000);   // Column address end2  0
LCD_WriteReg(0x0005,0x00eF);   // Column address end1  ef
LCD_WriteReg(0x0006,0x0000);   // Row address start2   
LCD_WriteReg(0x0007,0x0000);   // Row address start1   
LCD_WriteReg(0x0008,0x0001);   // Row address end2   
LCD_WriteReg(0x0009,0x003F);   // Row address end1   
LCD_WriteReg(0x0090,0x007F);   // SAP=0111 1111

//Display Setting
LCD_WriteReg(0x0001,0x0006);      // IDMON=0, INVON=1, NORON=1, PTLON=0
LCD_WriteReg(0x0016,0x0068);
LCD_WriteReg(0x0023,0x0095);   // N_DC=1001 0101   
LCD_WriteReg(0x0024,0x0095);   // P_DC=1001 0101   
LCD_WriteReg(0x0025,0x00FF);   // I_DC=1111 1111           
LCD_WriteReg(0x0027,0x0006);   // N_BP=0000 0110   
LCD_WriteReg(0x0028,0x0006);   // N_FP=0000 0110   
LCD_WriteReg(0x0029,0x0006);   // P_BP=0000 0110   
LCD_WriteReg(0x002A,0x0006);   // P_FP=0000 0110   
LCD_WriteReg(0x002C,0x0006);   // I_BP=0000 0110           
LCD_WriteReg(0x002D,0x0006);   // I_FP=0000 0110           
LCD_WriteReg(0x003A,0x0001);   // N_RTN=0000, N_NW=001           
LCD_WriteReg(0x003B,0x0000);   // P_RTN=0000, P_NW=001   
LCD_WriteReg(0x003C,0x00F0);   // I_RTN=1111, I_NW=000   
LCD_WriteReg(0x003D,0x0000);   // DIV=00   
FDelay10000X(10);
LCD_WriteReg(0x0035,0x0038);   // EQS=38h           
LCD_WriteReg(0x0036,0x0078);   // EQP=78h
LCD_WriteReg(0x003E,0x0038);   // SON=38h   
LCD_WriteReg(0x0040,0x000F);   // GDON=0Fh   
LCD_WriteReg(0x0041,0x00F0);   // GDOFF
//Power Supply Setting
LCD_WriteReg(0x0019,0x0049);                // OSCADJ=10 0000,OSD_EN=1 //60Hz   
LCD_WriteReg(0x0093,0x000C);                // RADJ=1100,   
FDelay10000X(5);
LCD_WriteReg(0x0020,0x0040);                // BT=0100         
LCD_WriteReg(0x001D,0x0007);                // VC1=111   
LCD_WriteReg(0x001E,0x0000);                // VC3=000   
LCD_WriteReg(0x001F,0x0007);                                //  VRH=0100 4.12V         
LCD_WriteReg(0x0044,0x0030);          // VCM=101 0000   3.21V   
LCD_WriteReg(0x0045,0x0009);          // VDV=1 0001  -1.19V   
FDelay10000X(5);
LCD_WriteReg(0x001C,0x0004);          // AP=100   
FDelay10000X(10);
LCD_WriteReg(0x001B,0x0018);          // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0   
FDelay10000X(20);
LCD_WriteReg(0x001B,0x0010);          // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0   
FDelay10000X(20);
LCD_WriteReg(0x0043,0x0080);          //set VCOMG=1   
FDelay10000X(5);
//Display ON Setting
LCD_WriteReg(0x0090,0x007f);  
LCD_WriteReg(0x0026,0x0004);   //GON=0, DTE=0, D=01   
FDelay10000X(20);
LCD_WriteReg(0x0026,0x003C);   //GON=1, DTE=1, D=11
}

void LCD_SetCursor(unsigned short int Xpos, unsigned short int Ypos)
{
LCD_WriteReg(0x06,Ypos>>8);
LCD_WriteReg(0x07,Ypos);
LCD_WriteReg(0x02,Xpos>>8);
LCD_WriteReg(0x03,Xpos);
}

unsigned short int GetPoint(unsigned short int Xpos, unsigned short int Ypos)
{
unsigned short int temp1,temp2;
LCD_SetCursor(Xpos,Ypos);
LCD->LCD_REG = 0x0022;
temp1 = LCD->LCD_RAM;
temp2 = LCD->LCD_RAM;
}

结果:
temp1:0x00fc,  temp2:0x0000.
沙发
harvest000|  楼主 | 2010-12-18 11:39 | 只看该作者
temp2 = LCD->LCD_RAM; 改为8位读即可。

使用特权

评论回复
板凳
playlinus| | 2012-2-18 17:24 | 只看该作者
楼主,问题解决了没有,我也遇到同样的问题,用的STM32,读出的数一直是0x00FC , 如果有解决,请帮忙复下, 我的QQ: 369122197

先谢过了

使用特权

评论回复
地板
zhjb1| | 2023-1-6 19:02 | 只看该作者
我也在试,出来结果转告

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

15

帖子

0

粉丝