打印
[STM32F1]

fsmc总线驱动RA8806LCD屏异常

[复制链接]
1061|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jiandandan168|  楼主 | 2015-9-21 10:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
新调试RA8806 LCD显示屏,分辨率320*240,单纯用IO模拟可以正常驱动,但是采用fsmc总线模式就没有任何反应,哪位大神帮看看我的配置有啥问题??谢谢??RS线接的是A0



#define Bank1_LCD_C    ((uint32_t)0x6C000001)    //disp Data ADDR RS=1
#define Bank1_LCD_D    ((uint32_t)0x6C000000)     //disp Reg ADDR RS=0


void FSMC_lcd_Init(void)
{
  FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
  FSMC_NORSRAMTimingInitTypeDef  p;
  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_0 | GPIO_Pin_1 | GPIO_Pin_14 | GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;
  GPIO_Init(GPIOE, &GPIO_InitStructure);


  /* NOE and NWE configuration */  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_5;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

  /*NWAIT*/
          GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;                                                            
          GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;

         GPIO_Init(GPIOD, &GPIO_InitStructure);


  //RST引脚
  GPIO_InitStructure.GPIO_Pin =GPIO_Pin_11;
  GPIO_InitStructure.GPIO_Mode =GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed =GPIO_Speed_50MHz;
  GPIO_Init(GPIOG,&GPIO_InitStructure);

  // 设置PF.00(A0 (RS))  为复用推挽输出
  GPIO_InitStructure.GPIO_Pin =GPIO_Pin_0;
  GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed =GPIO_Speed_50MHz;
  GPIO_Init(GPIOF,&GPIO_InitStructure);

  // NE4 configuration
  // 设置PG.12(NE4 (LCD/CS)) 为复用推挽输出 - CE3(LCD /CS)
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
  GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed =GPIO_Speed_50MHz;
  GPIO_Init(GPIOG, &GPIO_InitStructure);

  LCD_RST_RESET;
  LCD_RD_SET;
  LCD_WD_SET;

  LCD_CS_SET;

/*-- FSMC Configuration ------------------------------------------------------*/
  p.FSMC_AddressSetupTime =5;   //地址建立时间(ADDSET)为1个HCLK 1/72M=13.5ns
  p.FSMC_AddressHoldTime =0;    //地址保持时间(ADDHLD)模式A未用到
  p.FSMC_DataSetupTime =50;      //数据保持时间(DATAST)
  p.FSMC_BusTurnAroundDuration = 0;  //总线恢复时间
  p.FSMC_CLKDivision = 0;  //始终分频银子
  p.FSMC_DataLatency = 0; //数据产生时间
  p.FSMC_AccessMode = FSMC_AccessMode_A; //模式A

  FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;
  FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;  //禁止地址数据线服用
  FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;   //存储器类型为SRAM
  FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;  //存储器数据宽度为8位
  FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; //关闭突发模式访问
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; //等待模式优先级,只有在是能突发访问模式有效
  FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;  //关闭Wrapped burst access mode,只有在使能突发访问模式才有效
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; //等待信号设置,只有在使能突发访问模式才有效
  FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;   //使能这个BANK的写操作
  FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; //使能/关闭等待信息设置,只在使能突发访问模式才有效
  FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable; //关闭Extend Mode
  FSMC_NORSRAMInitStructure.FSMC_AsyncWait = FSMC_AsyncWait_Disable;
  FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;  //关闭Write Burst Mode  
  FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
  FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;

  FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);

  // Enable FSMC Bank1_SRAM Bank
  FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);  
}


//软复位
void LCD_SOFTRST()
{
    mDelaymS(2);
    LCD_RST_RESET;
    mDelaymS(10);
    LCD_RST_SET;
    mDelaymS(5);
}


//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
void LCD_CmdWrite(unsigned char index)//8080
{       
        *(__IO uint8_t *) (Bank1_LCD_C)= index;

       
}

//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

void LCD_DataWrite(unsigned char val)
{      
        while(BUSY==0);
        *(__IO uint8_t *) (Bank1_LCD_D)= val;

       
}

//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
unsigned char LCD_CmdRead(unsigned char index)
{  
        unsigned char Data;
       
        *(__IO uint8_t *) (Bank1_LCD_C)= index;
        *(__IO uint8_t *) (Bank1_LCD_D)= 0xFF;

        Data = *(__IO uint8_t *) (Bank1_LCD_D);
        return Data;
}


沙发
mmuuss586| | 2015-9-21 12:38 | 只看该作者
用示波器看看,2者时序的区别;

使用特权

评论回复
板凳
jiandandan168|  楼主 | 2015-9-21 13:41 | 只看该作者
本来我也是这么想的,但是公司示波器有问题,所以才想先在论坛上问问大神们有没有类似调试经验

使用特权

评论回复
地板
jiandandan168|  楼主 | 2015-9-21 16:13 | 只看该作者
问题已经解决,是由于我的读函数多了一句  *(__IO uint8_t *) (Bank1_LCD_D)= 0xFF;导致,目前已经可以使用了。

使用特权

评论回复
5
bbapple| | 2015-9-21 17:55 | 只看该作者
哈哈,这么快就解决了呀!

使用特权

评论回复
6
airwill| | 2015-9-21 17:55 | 只看该作者
支持一下楼主, 这类问题, 往往需要验证时序来解决.

使用特权

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

本版积分规则

1

主题

17

帖子

0

粉丝