问答

汇集网友智慧,解决技术难题

21ic问答首页 - AT32F403AVG的XMC问题?

AT32F403AVG的XMC问题?

hubeiluhua2021-03-28
回答 +关注 27
6751人浏览 12人回答问题 分享 举报
12 个回答
  • 明早实际debug分析过再回复你哈。方便的话可以留个联系方式
  • 再来AT的,帮我看看,感觉不是初始代码的问题。
    void XMC_init(void)
    {
      XMC_NORSRAMInitType  XMC_NORSRAMInitStruct;
      XMC_NORSRAMTimingInitType  XMC_NORSRAMTimingInitStruct = {0};
      GPIO_InitType GPIO_InitStructure;

      /* Enable the GPIO Clock */
      RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_GPIOB|RCC_APB2PERIPH_GPIOC | RCC_APB2PERIPH_GPIOA | RCC_APB2PERIPH_GPIOD |RCC_APB2PERIPH_AFIO, ENABLE);
      /* Enable the XMC Clock */
      RCC_AHBPeriphClockCmd(RCC_AHBPERIPH_XMC, ENABLE);
      /* REMAP */
      GPIO_PinsRemapConfig(AFIO_MAP7_XMC_0001,ENABLE);
      /*-- GPIO Configuration ------------------------------------------------------*/
      /*!< LCD Data lines configuration */
      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_6 | GPIO_Pins_11 | GPIO_Pins_12;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
      GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
      GPIO_Init(GPIOC, &GPIO_InitStructure);

      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_14;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
      GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
      GPIO_Init(GPIOB, &GPIO_InitStructure);

      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_2 | GPIO_Pins_3 | GPIO_Pins_4 | GPIO_Pins_5;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
      GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
      GPIO_Init(GPIOA, &GPIO_InitStructure);
       
      /*!< LCD Reset lines configuration */
      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_10;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT_PP;
      GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
      GPIO_Init(GPIOB, &GPIO_InitStructure);

      /*!< LCD RS/CS/WR/RD lines configuration */
      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_2;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
      GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
      GPIO_Init(GPIOD, &GPIO_InitStructure);

      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_5;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
      GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
      GPIO_Init(GPIOC, &GPIO_InitStructure);

      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_3 | GPIO_Pins_4;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
      GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
      GPIO_Init(GPIOC, &GPIO_InitStructure);


      /*-- FSMC Configuration ------------------------------------------------------*/
      XMC_NORSRAMTimingInitStruct.XMC_AdrOpTime = 0x02;   
      XMC_NORSRAMTimingInitStruct.XMC_AdrHoldTime = 0x00;
      XMC_NORSRAMTimingInitStruct.XMC_DataOpTime = 0x02;
      XMC_NORSRAMTimingInitStruct.XMC_IntervalBetweenOP = 0x00;   
      XMC_NORSRAMTimingInitStruct.XMC_CLKPsc = 0x00;
      XMC_NORSRAMTimingInitStruct.XMC_DataStableTime = 0x00;
      XMC_NORSRAMTimingInitStruct.XMC_Mode = XMC_Mode_A;

      XMC_NORSRAMInitStruct.XMC_Bank = XMC_Bank1_NORSRAM4;
      XMC_NORSRAMInitStruct.XMC_DataAdrMux = XMC_DataAdrMux_Disable;   
      XMC_NORSRAMInitStruct.XMC_Dev = XMC_Dev_SRAM;   
      XMC_NORSRAMInitStruct.XMC_BusType = XMC_BusType_8b;
      XMC_NORSRAMInitStruct.XMC_EnableBurstMode = XMC_BurstMode_Disable;
      XMC_NORSRAMInitStruct.XMC_EnableAsynWait = XMC_AsynWait_Disable;
      XMC_NORSRAMInitStruct.XMC_WaitSignalLv = XMC_WaitSignalLv_Low;   
      XMC_NORSRAMInitStruct.XMC_EnableBurstModeSplit = XMC_BurstModeSplit_Disable;
      XMC_NORSRAMInitStruct.XMC_WaitSignalConfig = XMC_WaitSignalConfig_BeforeWaitState;
      XMC_NORSRAMInitStruct.XMC_EnableWrite = XMC_WriteOperation_Enable;
      XMC_NORSRAMInitStruct.XMC_EnableWaitSignal = XMC_WaitSignal_Disable;
      XMC_NORSRAMInitStruct.XMC_EnableWriteTiming = XMC_WriteTiming_Enable;
      XMC_NORSRAMInitStruct.XMC_WriteBurstSyn = XMC_WriteBurstSyn_Disable;
       
      XMC_NORSRAMInitStruct.XMC_WTimingStruct = &XMC_NORSRAMTimingInitStruct;
      XMC_NORSRAMInitStruct.XMC_RWTimingStruct = &XMC_NORSRAMTimingInitStruct;
      XMC_NORSRAMInit(&XMC_NORSRAMInitStruct);
      /*!< Enable FSMC Bank1_SRAM Bank */
      XMC_NORSRAMCmd(XMC_Bank1_NORSRAM4, ENABLE);
    }
  • 贴子超长了,把代码写出来,先来ST的
    void init_fsmc(void)
    {
        FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
        FSMC_NORSRAMTimingInitTypeDef  p;

        /* FSMC GPIO configure */
        {
            GPIO_InitTypeDef GPIO_InitStructure;
            RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF
                                   | RCC_APB2Periph_GPIOG, ENABLE);
            RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
               
            GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF_PP;
            GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

            /*
            FSMC_D0 ~ FSMC_D3
            PD14 FSMC_D0   PD15 FSMC_D1   PD0  FSMC_D2   PD1  FSMC_D3
            */
            GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_14 | GPIO_Pin_15;
            GPIO_Init(GPIOD,&GPIO_InitStructure);

            /*
            FSMC_D4 ~ FSMC_D7
            PE7 ~ PE10  
            */
            GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 ;
            GPIO_Init(GPIOE,&GPIO_InitStructure);

            /* RD-PD4 WR-PD5 */
            GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_5;//GPIO_Pin_4 |
            GPIO_Init(GPIOD,&GPIO_InitStructure);
        }

        /*-- FSMC Configuration ------------------------------------------------------*/      
        p.FSMC_AddressSetupTime = 2;   //0     8
        p.FSMC_AddressHoldTime = 0;      //0     8
        p.FSMC_DataSetupTime = 2;     //2    10
        p.FSMC_BusTurnAroundDuration = 0;//0   3
        p.FSMC_CLKDivision = 0;    //3     72/(3+1) =18M
        p.FSMC_DataLatency = 0; //0            2
        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_8b;      
        FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
        FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_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_Enable;
        FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;   
       
        FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
        FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;

        FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);

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

12

您需要登录后才可以回复 登录 | 注册