STM32F103VET62.8寸TFTLCDDriver问题。

danqiuyizhui   2009-11-16 10:37 楼主


#include "includes.h"
#include "lcd204.h"
#include "fonts.h"

typedef struct
{
  vu16 LCD_REG;
  vu16 LCD_RAM;
} LCD_TypeDef;

#define LCD_BASE        ((u32)(0x60020000))
#define LCD             ((LCD_TypeDef *) LCD_BASE)

static  vu16 TextColor = 0x0000, BackColor = 0xFFFF;

void Delayms(u16 x)
{
u32 i;
for(i=0;i<x*10000;i++)
  ;
}
void st7781_Initializtion()
{
  LCD_WriteReg(0x0000,0x0001);
  Delayms(5);
  // Start Initial Sequence
  LCD_WriteReg(0x00FF,0x0001);
  LCD_WriteReg(0x00F3,0x0008);
  LCD_WriteReg(0x0001,0x0100);
  LCD_WriteReg(0x0002,0x0700);
  LCD_WriteReg(0x0003,0x1030);  //0x1030
  LCD_WriteReg(0x0008,0x0302);
  LCD_WriteReg(0x0008,0x0207);
  LCD_WriteReg(0x0009,0x0000);
  LCD_WriteReg(0x000A,0x0000);
  LCD_WriteReg(0x0010,0x0000);  //0x0790
  LCD_WriteReg(0x0011,0x0005);
  LCD_WriteReg(0x0012,0x0000);
  LCD_WriteReg(0x0013,0x0000);
  Delayms(50);
  LCD_WriteReg(0x0010,0x12B0);
  Delayms(50);
  LCD_WriteReg(0x0011,0x0007);
  Delayms(50);
  LCD_WriteReg(0x0012,0x008B);
  Delayms(50);
  LCD_WriteReg(0x0013,0x1700);
  Delayms(50);
  LCD_WriteReg(0x0029,0x0022);
  
  //################# void Gamma_Set(void)
  LCD_WriteReg(0x0030,0x0000);
  LCD_WriteReg(0x0031,0x0707);
  LCD_WriteReg(0x0032,0x0505);
  LCD_WriteReg(0x0035,0x0107);
  LCD_WriteReg(0x0036,0x0008);
  LCD_WriteReg(0x0037,0x0000);
  LCD_WriteReg(0x0038,0x0202);
  LCD_WriteReg(0x0039,0x0106);
  LCD_WriteReg(0x003C,0x0202);
  LCD_WriteReg(0x003D,0x0408);
  Delayms(50);
  
  
  LCD_WriteReg(0x0050,0x0000);  
  LCD_WriteReg(0x0051,0x00EF);  
  LCD_WriteReg(0x0052,0x0000);  
  LCD_WriteReg(0x0053,0x013F);  
  LCD_WriteReg(0x0060,0xA700);  
  LCD_WriteReg(0x0061,0x0001);
  LCD_WriteReg(0x0090,0x0033);   
  LCD_WriteReg(0x002B,0x000B);  
  LCD_WriteReg(0x0007,0x0133);
  Delayms(50);
    LCD->LCD_REG = 0x0000;
    temp=LCD->LCD_RAM;
}
void STM3210E_LCD_Init(void)
{
  LCD_CtrlLinesConfig();
  LCD_FSMCConfig();
  Delayms(100);
  st7781_Initializtion();
}

void LCD_SetCursor(u16 Xpos, u16 Ypos)
{
  LCD_WriteReg(R32, Xpos);
  LCD_WriteReg(R33, Ypos);
}
void LCD_CtrlLinesConfig(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |
                         RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG |
                         RCC_APB2Periph_AFIO, ENABLE);
  GPIO_InitStructure.GPIO_Pin =GPIO_Pin_6;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  GPIO_WriteBit(GPIOC, GPIO_Pin_6, Bit_SET);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_7|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);

  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);
}

void LCD_FSMCConfig(void)
{
  FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
  FSMC_NORSRAMTimingInitTypeDef  p;

  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_NORSRAM1;
  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_AsyncWait = FSMC_AsyncWait_Disable;
  FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
  FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
  FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
  FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);  
  FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
}

void LCD_WriteReg(u16 LCD_Reg, u16 LCD_RegValue)
{
  LCD->LCD_REG = LCD_Reg;
  LCD->LCD_RAM = LCD_RegValue;
}

u16 LCD_ReadReg(u8 LCD_Reg)
{
  LCD->LCD_REG = LCD_Reg;
  return (LCD->LCD_RAM);
}

void LCD_WriteRAM_Prepare(void)
{
  LCD->LCD_REG = R34;
}

void LCD_WriteRAM(u16 RGB_Code)
{
  /* Write 16-bit GRAM Reg */
  LCD->LCD_RAM = RGB_Code;
}

u16 LCD_ReadRAM(void)
{
  LCD->LCD_REG = R34; /* Select GRAM Reg */
  return LCD->LCD_RAM;
}

驱动IC为ST7781,上述代码读ID已经正确,为0x7783,但显示屏没有反映,请大家帮帮忙。。谢谢了。

回复评论 (3)

原理图如下:

未命名.jpg (49.31 KB)

点赞  2009-11-16 10:39
                                 大家出来帮帮忙啊。在线等待大家的提示。
点赞  2009-11-16 11:06
                                 哦。正好是我用的这个屏啊。耀宇科技的吧。
点赞  2010-4-11 14:56
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复