OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2675|回复: 4

关于F103VE的FSMC设置

[复制链接]

1

主题

4

帖子

0

精华

新手上路

积分
21
金钱
21
注册时间
2016-10-11
在线时间
4 小时
发表于 2016-10-11 16:21:39 | 显示全部楼层 |阅读模式
1金钱
新做了一块板,VE带LCD和RAM,需要不同的FSMC配置,当然从实现功能上来说,这个板子只能做测试了。我想测试一下FSMC
现在单个调试都可以,但是我先配置了LCD的,显示正确后再配置RAM的FSMC ,好像没起作用,还是能够现实,RAM读写不对。
但是如果先配置RAM的,可以正确读写,然后配置为LCD的,可以显示。不知道哪错了,有高手帮我看看嘛,代码如下:
static void SRAM_FSMC_Config(void)
{
        GPIO_InitTypeDef GPIO_InitStructure;
        FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
    FSMC_NORSRAMTimingInitTypeDef  p;
   
    /* Enable the FSMC Clock */
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
   
    /* config lcd gpio clock base on FSMC */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE , ENABLE);
   
               
   /* config tft data lines base on FSMC
     * data lines,FSMC-D0~D15: PD 14 15 0 1,PE 7 8 9 10 11 12 13 14 15,PD 8 9 10
     */   
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 |
                                  GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;
    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);
   
    /* config tft control lines base on FSMC
     * PD4-FSMC_NOE  :RAM-RD
   * PD5-FSMC_NWE  :RAM-WR
     * PD7-FSMC_NE1  :RAM-CS
   * PD11-FSMC_A16 :RAM-DC
     */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
    GPIO_Init(GPIOD, &GPIO_InitStructure);  
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ;
    GPIO_Init(GPIOD, &GPIO_InitStructure);

    /* addr line define */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 |GPIO_Pin_3 | GPIO_Pin_4;
    GPIO_Init(GPIOE, &GPIO_InitStructure);
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
    GPIO_Init(GPIOB, &GPIO_InitStructure);
        
        FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, DISABLE);
      
    p.FSMC_AddressSetupTime = 0x15;     //µØÖ·½¨Á¢Ê±¼ä
    p.FSMC_AddressHoldTime = 0x15;     //µØÖ·±£³Öʱ¼ä
    p.FSMC_DataSetupTime = 0x255;         //Êý¾Ý½¨Á¢Ê±¼ä
    p.FSMC_BusTurnAroundDuration = 0x15;
    p.FSMC_CLKDivision = 0x00;
    p.FSMC_DataLatency = 0x00;

    p.FSMC_AccessMode = FSMC_AccessMode_B;     // Ò»°ãʹÓÃģʽBÀ´¿ØÖÆ
   
    FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
    FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Enable;
    FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR;
    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);
   
    /* Enable FSMC Bank1_SRAM Bank */
    FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);

static void LCD_GPIO_Config(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
   
    /* Enable the FSMC Clock */
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
   
    /* config lcd gpio clock base on FSMC */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE , ENABLE);
   
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
   
    /* config tft rst gpio */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;        
    GPIO_Init(GPIOE, &GPIO_InitStructure);
   
    /* config tft BL gpio */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 ;      
    GPIO_Init(GPIOA, &GPIO_InitStructure);            
   
    /* config tft data lines base on FSMC
     * data lines,FSMC-D0~D15: PD 14 15 0 1,PE 7 8 9 10 11 12 13 14 15,PD 8 9 10
     */   
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 |
                                  GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;
    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);
   
    /* config tft control lines base on FSMC
     * PD4-FSMC_NOE  CD-RD
   * PD5-FSMC_NWE  CD-WR
     * PD7-FSMC_NE1  CD-CS
   * PD11-FSMC_A16 CD-DC
     */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
    GPIO_Init(GPIOD, &GPIO_InitStructure);  
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ;
    GPIO_Init(GPIOD, &GPIO_InitStructure);

    /* addr line define */
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
   
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
    GPIO_Init(GPIOE, &GPIO_InitStructure);
   
    /* tft control gpio init */     
    GPIO_SetBits(GPIOE, GPIO_Pin_6);         // RST               
    GPIO_SetBits(GPIOD, GPIO_Pin_4);         // RD = 1  
    GPIO_SetBits(GPIOD, GPIO_Pin_5);         // WR = 1
        GPIO_SetBits(GPIOD, GPIO_Pin_11);         // RS
    GPIO_SetBits(GPIOD, GPIO_Pin_7);         //    CS = 1

        GPIO_SetBits(GPIOA, GPIO_Pin_1);          //    BL = 1
        
        
        //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
    //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
   
        //GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;    //°´¼ü OK
        //GPIO_Init(GPIOA, &GPIO_InitStructure);
                                                            // right          up           left        down
        //GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_1 | GPIO_Pin_5 | GPIO_Pin_6;        
        //GPIO_Init(GPIOE, &GPIO_InitStructure);

}

/*
* º¯ÊýÃû£ºLCD_FSMC_Config
* ÃèÊö  £ºLCD  FSMC ģʽÅäÖÃ
* ÊäÈë  £ºÎÞ
* Êä³ö  £ºÎÞ
* µ÷Óà £ºÄÚ²¿µ÷Óà       
*/

static void LCD_FSMC_Config(void)
{
    FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
    FSMC_NORSRAMTimingInitTypeDef  p;
   
   
    p.FSMC_AddressSetupTime = 0x02;     //µØÖ·½¨Á¢Ê±¼ä
    p.FSMC_AddressHoldTime = 0x00;     //µØÖ·±£³Öʱ¼ä
    p.FSMC_DataSetupTime = 0x05;         //Êý¾Ý½¨Á¢Ê±¼ä
    p.FSMC_BusTurnAroundDuration = 0x00;
    p.FSMC_CLKDivision = 0x00;
    p.FSMC_DataLatency = 0x00;

    p.FSMC_AccessMode = FSMC_AccessMode_B;     // Ò»°ãʹÓÃģʽBÀ´¿ØÖÆLCD
   
    FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
    FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
    FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR;
    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);
   
    /* Enable FSMC Bank1_SRAM Bank */
    FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);  
}

最佳答案

查看完整内容[请看2#楼]

可以了,好像是硬件的问题,片选容易乱,虚焊了好像。
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

1

主题

4

帖子

0

精华

新手上路

积分
21
金钱
21
注册时间
2016-10-11
在线时间
4 小时
 楼主| 发表于 2016-10-11 16:21:40 | 显示全部楼层
可以了,好像是硬件的问题,片选容易乱,虚焊了好像。
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165516
金钱
165516
注册时间
2010-12-1
在线时间
2116 小时
发表于 2016-10-12 21:36:32 | 显示全部楼层
VE只有100脚,外扩RAM,得加锁存器,你电路呢?
回复

使用道具 举报

1

主题

4

帖子

0

精华

新手上路

积分
21
金钱
21
注册时间
2016-10-11
在线时间
4 小时
 楼主| 发表于 2016-10-13 10:20:09 | 显示全部楼层
这个我还是知道的,锁存器也工作正常,能够读写SAM,只是,SAM和LCD ,一个数据地址复用,一个不复用,需要来回切换FSMC配置,主要现在来回切换有问题,没搞懂没啥
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165516
金钱
165516
注册时间
2010-12-1
在线时间
2116 小时
发表于 2016-10-14 20:24:08 | 显示全部楼层
jman009 发表于 2016-10-13 10:20
这个我还是知道的,锁存器也工作正常,能够读写SAM,只是,SAM和LCD ,一个数据地址复用,一个不复用,需要 ...

慢慢搞,呵呵
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-5-24 01:57

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表