你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

为什么我的STM32驱动不了TFT(9235)?

[复制链接]
zhangxiabo 提问时间:2010-9-19 09:56 /
     我用51都可以的,但stm32就不行,我的目的很简单,就让TFT显示出颜色就行,这是我的程序,让大家看看哪里不对:

#include "stm32f10x_lib.h"
#define  GPIOA_LCD_CS                   GPIO_Pin_1
#define  GPIOA_LCD_RS                   GPIO_Pin_2
#define  GPIOA_LCD_WR                   GPIO_Pin_3
#define  GPIOA_LCD_RD                   GPIO_Pin_8
#define  GPIOA_LCD_RESET                GPIO_Pin_11
#define ILI9325_CS_LOW()     GPIO_ResetBits(GPIOA,GPIOA_LCD_CS)
#define ILI9325_CS_HIGH()    GPIO_SetBits(GPIOA,GPIOA_LCD_CS)
#define ILI9325_RS_LOW()     GPIO_ResetBits(GPIOA,GPIOA_LCD_RS)
#define ILI9325_RS_HIGH()    GPIO_SetBits(GPIOA,GPIOA_LCD_RS)
#define ILI9325_WR_LOW()     GPIO_ResetBits(GPIOA,GPIOA_LCD_WR)
#define ILI9325_WR_HIGH()    GPIO_SetBits(GPIOA,GPIOA_LCD_WR)
#define ILI9325_RD_LOW()     GPIO_ResetBits(GPIOA,GPIOA_LCD_RD)
#define ILI9325_RD_HIGH()    GPIO_SetBits(GPIOA,GPIOA_LCD_RD)
#define ILI9325_RESET_LOW()  GPIO_ResetBits(GPIOA,GPIOA_LCD_RESET)
#define ILI9325_RESET_HIGH() GPIO_SetBits(GPIOA,GPIOA_LCD_RESET)
void RCC_Configuration(void)
{
  ErrorStatus HSEStartUpStatus;
  /* RCC system reset(for debug purpose) */
  RCC_DeInit();
  /* Enable HSE */
  RCC_HSEConfig(RCC_HSE_ON);
  /* Wait till HSE is ready */
  HSEStartUpStatus = RCC_WaitForHSEStartUp();
  if(HSEStartUpStatus == SUCCESS)
  {
    /* Enable Prefetch Buffer */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
    /* Flash 2 wait state */
    FLASH_SetLatency(FLASH_Latency_2);
    /* HCLK = SYSCLK */
    RCC_HCLKConfig(RCC_SYSCLK_Div1);
    /* PCLK2 = HCLK */
    RCC_PCLK2Config(RCC_HCLK_Div1);
    /* PCLK1 = HCLK/2 */
    RCC_PCLK1Config(RCC_HCLK_Div2);
    /* PLLCLK = 8MHz * 9 = 72 MHz */
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
    /* Enable PLL */
    RCC_PLLCmd(ENABLE);
    /* Wait till PLL is ready */
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
    {
    }
    /* Select PLL as system clock source */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
    /* Wait till PLL is used as system clock source */
    while(RCC_GetSYSCLKSource() != 0x08)
    {
    }
  }
}
void NVIC_Configuration(void)
{
 
#ifdef  VECT_TAB_RAM
  /* Set the Vector Table base location at 0x20000000 */
  NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else  /* VECT_TAB_FLASH  */
  /* Set the Vector Table base location at 0x08000000 */
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
}
void GPIO_Configuration(void)
{
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);
  GPIO_InitTypeDef GPIO_InitStructure;
  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
  /* Configure PD.7--PD.11 as Output push-pull */
  GPIO_InitStructure.GPIO_Pin = GPIOA_LCD_CS | GPIOA_LCD_RS | GPIOA_LCD_WR | GPIOA_LCD_RD |
                                GPIOA_LCD_RESET ;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  /* Configure PE.00 -- PE.15 as Output push-pull */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
}
//延时功能函数
void  ILI9325_Delay (int nCount)
{
  int  i;
  for (i = 0; i < nCount * 250; i++)
  { }
}
void ILI9325_WriteData(unsigned int Data)
{
  ILI9325_RS_HIGH();
  ILI9325_RD_HIGH();
  GPIO_Write(GPIOB,Data);
  ILI9325_WR_LOW();
  ILI9325_WR_HIGH();
}
void ILI9325_WriteCom(unsigned int Data)
{
  ILI9325_RS_LOW();
  ILI9325_RD_HIGH();
  GPIO_Write(GPIOB,Data);
  ILI9325_WR_LOW();
  ILI9325_WR_HIGH();
}
void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
  ILI9325_WriteCom(0x0020);ILI9325_WriteData(x1);
  ILI9325_WriteCom(0x0021);ILI9325_WriteData(y1);
  ILI9325_WriteCom(0x0050);ILI9325_WriteData(x1);
  ILI9325_WriteCom(0x0052);ILI9325_WriteData(y1);
  ILI9325_WriteCom(0x0051);ILI9325_WriteData(x2);
  ILI9325_WriteCom(0x0053);ILI9325_WriteData(y2);
  ILI9325_WriteCom(0x0022);
}
void ILI9325_Init(void)
{
  ILI9325_RESET_HIGH();
  ILI9325_Delay(5);
  ILI9325_RESET_LOW();                              
  ILI9325_Delay(5);
  ILI9325_RESET_HIGH();                   
  ILI9325_Delay(5);
  ILI9325_CS_LOW();
  ILI9325_WriteCom(0x00E5); ILI9325_WriteData(0x78F0); // set SRAM internal timing
 ILI9325_WriteCom(0x0001); ILI9325_WriteData(0x0100); // set SS and SM bit
 ILI9325_WriteCom(0x0002); ILI9325_WriteData(0x0700); // set 1 line inversion
 ILI9325_WriteCom(0x0003); ILI9325_WriteData(0x1030); // set GRAM write direction and BGR=1.
 ILI9325_WriteCom(0x0004); ILI9325_WriteData(0x0000); // Resize register
 ILI9325_WriteCom(0x0008); ILI9325_WriteData(0x0207); // set the back porch and front porch
 ILI9325_WriteCom(0x0009); ILI9325_WriteData(0x0000); // set non-display area refresh cycle ISC[3:0]
 ILI9325_WriteCom(0x000A); ILI9325_WriteData(0x0000); // FMARK function
 ILI9325_WriteCom(0x000C); ILI9325_WriteData(0x0000); // RGB interface setting
 ILI9325_WriteCom(0x000D); ILI9325_WriteData(0x0000); // Frame marker Position
 ILI9325_WriteCom(0x000F); ILI9325_WriteData(0x0000); // RGB interface polarity
 //*************Power On sequence ****************//
 ILI9325_WriteCom(0x0010); ILI9325_WriteData(0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
 ILI9325_WriteCom(0x0011); ILI9325_WriteData(0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
 ILI9325_WriteCom(0x0012); ILI9325_WriteData(0x0000); // VREG1OUT voltage
 ILI9325_WriteCom(0x0013); ILI9325_WriteData(0x0000); // VDV[4:0] for VCOM amplitude
 ILI9325_WriteCom(0x0007); ILI9325_WriteData(0x0001);
 ILI9325_Delay(50); // Dis-charge capacitor power voltage
 ILI9325_WriteCom(0x0010); ILI9325_WriteData(0x1090); // 1490//SAP, BT[3:0], AP, DSTB, SLP, STB
 ILI9325_WriteCom(0x0011); ILI9325_WriteData(0x0227); // DC1[2:0], DC0[2:0], VC[2:0]
 ILI9325_Delay(50); // Delay 50ms
 ILI9325_WriteCom(0x0012); ILI9325_WriteData(0x001F); //001C// Internal reference voltage= Vci;
 ILI9325_Delay(50); // Delay 50ms
 ILI9325_WriteCom(0x0013); ILI9325_WriteData(0x1500); //0x1000//1400   Set VDV[4:0] for VCOM amplitude  1A00
 ILI9325_WriteCom(0x0029); ILI9325_WriteData(0x0027); //0x0012 //001a  Set VCM[5:0] for VCOMH  //0x0025  0034
 ILI9325_WriteCom(0x002B); ILI9325_WriteData(0x000D); // Set Frame Rate   000C
 ILI9325_Delay(50); // Delay 50ms
 ILI9325_WriteCom(0x0020); ILI9325_WriteData(0x0000); // GRAM horizontal Address
 ILI9325_WriteCom(0x0021); ILI9325_WriteData(0x0000); // GRAM Vertical Address
 // ----------- Adjust the Gamma Curve ----------//
 ILI9325_WriteCom(0x0030); ILI9325_WriteData(0x0000);
 ILI9325_WriteCom(0x0031); ILI9325_WriteData(0x0707);
 ILI9325_WriteCom(0x0032); ILI9325_WriteData(0x0307);
 ILI9325_WriteCom(0x0035); ILI9325_WriteData(0x0200);
 ILI9325_WriteCom(0x0036); ILI9325_WriteData(0x0008);//0207
 ILI9325_WriteCom(0x0037); ILI9325_WriteData(0x0004);//0306
 ILI9325_WriteCom(0x0038); ILI9325_WriteData(0x0000);//0102
 ILI9325_WriteCom(0x0039); ILI9325_WriteData(0x0707);//0707
 ILI9325_WriteCom(0x003C); ILI9325_WriteData(0x0002);//0702
 ILI9325_WriteCom(0x003D); ILI9325_WriteData(0x1D04);//1604
 
 //------------------ Set GRAM area ---------------//
 ILI9325_WriteCom(0x0050); ILI9325_WriteData(0x0000); // Horizontal GRAM Start Address
 ILI9325_WriteCom(0x0051); ILI9325_WriteData(0x00EF); // Horizontal GRAM End Address
 ILI9325_WriteCom(0x0052); ILI9325_WriteData(0x0000); // Vertical GRAM Start Address
 ILI9325_WriteCom(0x0053); ILI9325_WriteData(0x013F); // Vertical GRAM Start Address
 ILI9325_WriteCom(0x0060); ILI9325_WriteData(0xA700); // Gate Scan Line
 ILI9325_WriteCom(0x0061); ILI9325_WriteData(0x0001); // NDL,VLE, REV
 ILI9325_WriteCom(0x006A); ILI9325_WriteData(0x0000); // set scrolling line
 //-------------- Partial Display Control ---------//
 ILI9325_WriteCom(0x0080); ILI9325_WriteData(0x0000);
 ILI9325_WriteCom(0x0081); ILI9325_WriteData(0x0000);
 ILI9325_WriteCom(0x0082); ILI9325_WriteData(0x0000);
 ILI9325_WriteCom(0x0083); ILI9325_WriteData(0x0000);
 ILI9325_WriteCom(0x0084); ILI9325_WriteData(0x0000);
 ILI9325_WriteCom(0x0085); ILI9325_WriteData(0x0000);
 //-------------- Panel Control -------------------//
 ILI9325_WriteCom(0x0090); ILI9325_WriteData(0x0010);
 ILI9325_WriteCom(0x0092); ILI9325_WriteData(0x0600);
 ILI9325_WriteCom(0x0007); ILI9325_WriteData(0x0133); // 262K color and display ON
        ILI9325_CS_HIGH();
}

void Pant(unsigned int Data)
{
  int i,j;
  ILI9325_CS_LOW();
  Address_set(0,0,240,320);
  for(i=0;i
收藏 评论8 发布时间:2010-9-19 09:56

举报

8个回答
废鱼 回答时间:2010-9-19 10:23:16

RE:为什么我的STM32驱动不了TFT(9235)?

STM32和51是不一样的,建议你好好的看看STM的IO口操作、总线操作。
zhangxiabo 回答时间:2010-9-19 16:43:36

回复:为什么我的STM32驱动不了TFT(9235)?

回复第 2 楼 安 于2010-09-19 02:23:16发表:
STM32和51是不一样的,建议你好好的看看STM的IO口操作、总线操作。 

我已经做过一些stm32的IO口的实验了
废鱼 回答时间:2010-9-20 08:52:44

RE:为什么我的STM32驱动不了TFT(9235)?

那现在你可以对LCD的颜色做改变吗?
废鱼 回答时间:2010-9-20 08:56:42

RE:为什么我的STM32驱动不了TFT(9235)?

你显示不了颜色,主要的原因是IO管脚的操作。
zhangxiabo 回答时间:2010-9-21 23:47:07

回复:为什么我的STM32驱动不了TFT(9235)?

回复第 5 楼 安 于2010-09-20 00:56:42发表:
你显示不了颜色,主要的原因是IO管脚的操作。 

没有启动AFIO,所以PB3和PB4并不是I/O。
废鱼 回答时间:2010-9-23 11:10:45

RE:为什么我的STM32驱动不了TFT(9235)?

能不能把你的LCD的资料发上来,我看看手册。
yushan210 回答时间:2013-10-30 16:56:17

RE:为什么我的STM32驱动不了TFT(9235)?

哥们 你的屏显示了吗
轻舟 回答时间:2013-12-7 17:22:54

RE:为什么我的STM32驱动不了TFT(9235)?

看看GPIO_Write(GPIOB,Data);是否真的从IO口驱动数据。
其他脚也一一检查一下。

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32Cube扩展软件包
意法半导体边缘AI套件
ST - 理想汽车豪华SUV案例
ST意法半导体智能家居案例
STM32 ARM Cortex 32位微控制器
关注我们
st-img 微信公众号
st-img 手机版