Advertisement
Guest User

Untitled

a guest
Aug 8th, 2012
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 21.02 KB | None | 0 0
  1. /**
  2.   ******************************************************************************
  3.   * @file    system_stm32f4xx.c
  4.   * @author  MCD Application Team
  5.   * @version V1.0.1
  6.   * @date    07-August-2012
  7.   * @brief   CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
  8.   *          This file contains the system clock configuration for STM32F4xx devices,
  9.   *          and is generated by the clock configuration tool
  10.   *          stm32f4xx_Clock_Configuration_V1.0.1.xls
  11.   *            
  12.   * 1.  This file provides two functions and one global variable to be called from
  13.   *     user application:
  14.   *      - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
  15.   *                      and Divider factors, AHB/APBx prescalers and Flash settings),
  16.   *                      depending on the configuration made in the clock xls tool.
  17.   *                      This function is called at startup just after reset and
  18.   *                      before branch to main program. This call is made inside
  19.   *                      the "startup_stm32f4xx.s" file.
  20.   *
  21.   *      - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
  22.   *                                  by the user application to setup the SysTick
  23.   *                                  timer or configure other parameters.
  24.   *                                    
  25.   *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
  26.   *                                 be called whenever the core clock is changed
  27.   *                                 during program execution.
  28.   *
  29.   * 2. After each device reset the HSI (16 MHz) is used as system clock source.
  30.   *    Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to
  31.   *    configure the system clock before to branch to main program.
  32.   *
  33.   * 3. If the system clock source selected by user fails to startup, the SystemInit()
  34.   *    function will do nothing and HSI still used as system clock source. User can
  35.   *    add some code to deal with this issue inside the SetSysClock() function.
  36.   *
  37.   * 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define
  38.   *    in "stm32f4xx.h" file. When HSE is used as system clock source, directly or
  39.   *    through PLL, and you are using different crystal you have to adapt the HSE
  40.   *    value to your own configuration.
  41.   *
  42.   * 5. This file configures the system clock as follows:
  43.   *=============================================================================
  44.   *=============================================================================
  45.   *        Supported STM32F4xx device revision    | Rev A
  46.   *-----------------------------------------------------------------------------
  47.   *        System Clock source                    | PLL (HSE)
  48.   *-----------------------------------------------------------------------------
  49.   *        SYSCLK(Hz)                             | 168000000
  50.   *-----------------------------------------------------------------------------
  51.   *        HCLK(Hz)                               | 168000000
  52.   *-----------------------------------------------------------------------------
  53.   *        AHB Prescaler                          | 1
  54.   *-----------------------------------------------------------------------------
  55.   *        APB1 Prescaler                         | 4
  56.   *-----------------------------------------------------------------------------
  57.   *        APB2 Prescaler                         | 2
  58.   *-----------------------------------------------------------------------------
  59.   *        HSE Frequency(Hz)                      | 25000000
  60.   *-----------------------------------------------------------------------------
  61.   *        PLL_M                                  | 25
  62.   *-----------------------------------------------------------------------------
  63.   *        PLL_N                                  | 336
  64.   *-----------------------------------------------------------------------------
  65.   *        PLL_P                                  | 2
  66.   *-----------------------------------------------------------------------------
  67.   *        PLL_Q                                  | 7
  68.   *-----------------------------------------------------------------------------
  69.   *        PLLI2S_N                               | NA
  70.   *-----------------------------------------------------------------------------
  71.   *        PLLI2S_R                               | NA
  72.   *-----------------------------------------------------------------------------
  73.   *        I2S input clock                        | NA
  74.   *-----------------------------------------------------------------------------
  75.   *        VDD(V)                                 | 3.3
  76.   *-----------------------------------------------------------------------------
  77.   *        Main regulator output voltage          | Scale1 mode
  78.   *-----------------------------------------------------------------------------
  79.   *        Flash Latency(WS)                      | 5
  80.   *-----------------------------------------------------------------------------
  81.   *        Prefetch Buffer                        | OFF
  82.   *-----------------------------------------------------------------------------
  83.   *        Instruction cache                      | ON
  84.   *-----------------------------------------------------------------------------
  85.   *        Data cache                             | ON
  86.   *-----------------------------------------------------------------------------
  87.   *=============================================================================
  88.   ******************************************************************************
  89.   * @attention
  90.   *
  91.   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  92.   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  93.   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  94.   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  95.   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  96.   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  97.   *
  98.   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  99.   ******************************************************************************
  100.   */
  101.  
  102. /** @addtogroup CMSIS
  103.   * @{
  104.   */
  105.  
  106. /** @addtogroup stm32f4xx_system
  107.   * @{
  108.   */  
  109.  
  110. /** @addtogroup STM32F4xx_System_Private_Includes
  111.   * @{
  112.   */
  113.  
  114. #include "stm32f4xx.h"
  115.  
  116. /**
  117.   * @}
  118.   */
  119.  
  120. /** @addtogroup STM32F4xx_System_Private_TypesDefinitions
  121.   * @{
  122.   */
  123.  
  124. /**
  125.   * @}
  126.   */
  127.  
  128. /** @addtogroup STM32F4xx_System_Private_Defines
  129.   * @{
  130.   */
  131.  
  132. /************************* Miscellaneous Configuration ************************/
  133. /*!< Uncomment the following line if you need to use external SRAM mounted
  134.      on STM324xG_EVAL board as data memory  */
  135. /* #define DATA_IN_ExtSRAM */
  136.  
  137. /*!< Uncomment the following line if you need to relocate your vector Table in
  138.      Internal SRAM. */
  139. /* #define VECT_TAB_SRAM */
  140. #define VECT_TAB_OFFSET  0x00 /*!< Vector Table base offset field.
  141.                                    This value must be a multiple of 0x200. */
  142. /******************************************************************************/
  143.  
  144. /************************* PLL Parameters *************************************/
  145. /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
  146. #define PLL_M      25
  147. #define PLL_N      336
  148.  
  149. /* SYSCLK = PLL_VCO / PLL_P */
  150. #define PLL_P      2
  151.  
  152. /* USB OTG FS, SDIO and RNG Clock =  PLL_VCO / PLLQ */
  153. #define PLL_Q      7
  154.  
  155. /******************************************************************************/
  156.  
  157. /**
  158.   * @}
  159.   */
  160.  
  161. /** @addtogroup STM32F4xx_System_Private_Macros
  162.   * @{
  163.   */
  164.  
  165. /**
  166.   * @}
  167.   */
  168.  
  169. /** @addtogroup STM32F4xx_System_Private_Variables
  170.   * @{
  171.   */
  172.  
  173.   uint32_t SystemCoreClock = 168000000;
  174.  
  175.   __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
  176.  
  177. /**
  178.   * @}
  179.   */
  180.  
  181. /** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
  182.   * @{
  183.   */
  184.  
  185. static void SetSysClock(void);
  186. #ifdef DATA_IN_ExtSRAM
  187.   static void SystemInit_ExtMemCtl(void);
  188. #endif /* DATA_IN_ExtSRAM */
  189.  
  190. /**
  191.   * @}
  192.   */
  193.  
  194. /** @addtogroup STM32F4xx_System_Private_Functions
  195.   * @{
  196.   */
  197.  
  198. /**
  199.   * @brief  Setup the microcontroller system
  200.   *         Initialize the Embedded Flash Interface, the PLL and update the
  201.   *         SystemFrequency variable.
  202.   * @param  None
  203.   * @retval None
  204.   */
  205. void SystemInit(void)
  206. {
  207.   /* FPU settings ------------------------------------------------------------*/
  208.   #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
  209.     SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */
  210.   #endif
  211.   /* Reset the RCC clock configuration to the default reset state ------------*/
  212.   /* Set HSION bit */
  213.   RCC->CR |= (uint32_t)0x00000001;
  214.  
  215.   /* Reset CFGR register */
  216.   RCC->CFGR = 0x00000000;
  217.  
  218.   /* Reset HSEON, CSSON and PLLON bits */
  219.   RCC->CR &= (uint32_t)0xFEF6FFFF;
  220.  
  221.   /* Reset PLLCFGR register */
  222.   RCC->PLLCFGR = 0x24003010;
  223.  
  224.   /* Reset HSEBYP bit */
  225.   RCC->CR &= (uint32_t)0xFFFBFFFF;
  226.  
  227.   /* Disable all interrupts */
  228.   RCC->CIR = 0x00000000;
  229.  
  230. #ifdef DATA_IN_ExtSRAM
  231.   SystemInit_ExtMemCtl();
  232. #endif /* DATA_IN_ExtSRAM */
  233.          
  234.   /* Configure the System clock source, PLL Multiplier and Divider factors,
  235.      AHB/APBx prescalers and Flash settings ----------------------------------*/
  236.   SetSysClock();
  237.  
  238.   /* Configure the Vector Table location add offset address ------------------*/
  239. #ifdef VECT_TAB_SRAM
  240.   SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
  241. #else
  242.   SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
  243. #endif
  244. }
  245.  
  246. /**
  247.    * @brief  Update SystemCoreClock variable according to Clock Register Values.
  248.   *         The SystemCoreClock variable contains the core clock (HCLK), it can
  249.   *         be used by the user application to setup the SysTick timer or configure
  250.   *         other parameters.
  251.   *          
  252.   * @note   Each time the core clock (HCLK) changes, this function must be called
  253.   *         to update SystemCoreClock variable value. Otherwise, any configuration
  254.   *         based on this variable will be incorrect.        
  255.   *    
  256.   * @note   - The system frequency computed by this function is not the real
  257.   *           frequency in the chip. It is calculated based on the predefined
  258.   *           constant and the selected clock source:
  259.   *            
  260.   *           - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
  261.   *                                              
  262.   *           - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
  263.   *                          
  264.   *           - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
  265.   *             or HSI_VALUE(*) multiplied/divided by the PLL factors.
  266.   *        
  267.   *         (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value
  268.   *             16 MHz) but the real value may vary depending on the variations
  269.   *             in voltage and temperature.  
  270.   *    
  271.   *         (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value
  272.   *              25 MHz), user has to ensure that HSE_VALUE is same as the real
  273.   *              frequency of the crystal used. Otherwise, this function may
  274.   *              have wrong result.
  275.   *                
  276.   *         - The result of this function could be not correct when using fractional
  277.   *           value for HSE crystal.
  278.   *    
  279.   * @param  None
  280.   * @retval None
  281.   */
  282. void SystemCoreClockUpdate(void)
  283. {
  284.   uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
  285.  
  286.   /* Get SYSCLK source -------------------------------------------------------*/
  287.   tmp = RCC->CFGR & RCC_CFGR_SWS;
  288.  
  289.   switch (tmp)
  290.   {
  291.     case 0x00:  /* HSI used as system clock source */
  292.       SystemCoreClock = HSI_VALUE;
  293.       break;
  294.     case 0x04:  /* HSE used as system clock source */
  295.       SystemCoreClock = HSE_VALUE;
  296.       break;
  297.     case 0x08:  /* PLL used as system clock source */
  298.  
  299.       /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
  300.          SYSCLK = PLL_VCO / PLL_P
  301.          */    
  302.       pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
  303.       pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
  304.      
  305.       if (pllsource != 0)
  306.       {
  307.         /* HSE used as PLL clock source */
  308.         pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  309.       }
  310.       else
  311.       {
  312.         /* HSI used as PLL clock source */
  313.         pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);      
  314.       }
  315.  
  316.       pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
  317.       SystemCoreClock = pllvco/pllp;
  318.       break;
  319.     default:
  320.       SystemCoreClock = HSI_VALUE;
  321.       break;
  322.   }
  323.   /* Compute HCLK frequency --------------------------------------------------*/
  324.   /* Get HCLK prescaler */
  325.   tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
  326.   /* HCLK frequency */
  327.   SystemCoreClock >>= tmp;
  328. }
  329.  
  330. /**
  331.   * @brief  Configures the System clock source, PLL Multiplier and Divider factors,
  332.   *         AHB/APBx prescalers and Flash settings
  333.   * @Note   This function should be called only once the RCC clock configuration  
  334.   *         is reset to the default reset state (done in SystemInit() function).  
  335.   * @param  None
  336.   * @retval None
  337.   */
  338. static void SetSysClock(void)
  339. {
  340. /******************************************************************************/
  341. /*            PLL (clocked by HSE) used as System clock source                */
  342. /******************************************************************************/
  343.   __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
  344.  
  345.   /* Enable HSE */
  346.   RCC->CR |= ((uint32_t)RCC_CR_HSEON);
  347.  
  348.   /* Wait till HSE is ready and if Time out is reached exit */
  349.   do
  350.   {
  351.     HSEStatus = RCC->CR & RCC_CR_HSERDY;
  352.     StartUpCounter++;
  353.   } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
  354.  
  355.   if ((RCC->CR & RCC_CR_HSERDY) != RESET)
  356.   {
  357.     HSEStatus = (uint32_t)0x01;
  358.   }
  359.   else
  360.   {
  361.     HSEStatus = (uint32_t)0x00;
  362.   }
  363.  
  364.   if (HSEStatus == (uint32_t)0x01)
  365.   {
  366.     /* Select regulator voltage output Scale 1 mode, System frequency up to 168 MHz */
  367.     RCC->APB1ENR |= RCC_APB1ENR_PWREN;
  368.     PWR->CR |= PWR_CR_VOS;
  369.  
  370.     /* HCLK = SYSCLK / 1*/
  371.     RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
  372.      
  373.     /* PCLK2 = HCLK / 2*/
  374.     RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
  375.    
  376.     /* PCLK1 = HCLK / 4*/
  377.     RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
  378.  
  379.     /* Configure the main PLL */
  380.     RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
  381.                    (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
  382.  
  383.     /* Enable the main PLL */
  384.     RCC->CR |= RCC_CR_PLLON;
  385.  
  386.     /* Wait till the main PLL is ready */
  387.     while((RCC->CR & RCC_CR_PLLRDY) == 0)
  388.     {
  389.     }
  390.    
  391.     /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  392.     FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
  393.  
  394.     /* Select the main PLL as system clock source */
  395.     RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
  396.     RCC->CFGR |= RCC_CFGR_SW_PLL;
  397.  
  398.     /* Wait till the main PLL is used as system clock source */
  399.     while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
  400.     {
  401.     }
  402.   }
  403.   else
  404.   { /* If HSE fails to start-up, the application will have wrong clock
  405.          configuration. User can add here some code to deal with this error */
  406.   }
  407.  
  408. }
  409.  
  410. /**
  411.   * @brief  Setup the external memory controller. Called in startup_stm32f4xx.s
  412.   *          before jump to __main
  413.   * @param  None
  414.   * @retval None
  415.   */
  416. #ifdef DATA_IN_ExtSRAM
  417. /**
  418.   * @brief  Setup the external memory controller.
  419.   *         Called in startup_stm32f4xx.s before jump to main.
  420.   *         This function configures the external SRAM mounted on STM324xG_EVAL board
  421.   *         This SRAM will be used as program data memory (including heap and stack).
  422.   * @param  None
  423.   * @retval None
  424.   */
  425. void SystemInit_ExtMemCtl(void)
  426. {
  427. /*-- GPIOs Configuration -----------------------------------------------------*/
  428. /*
  429.  +-------------------+--------------------+------------------+------------------+
  430.  +                       SRAM pins assignment                                   +
  431.  +-------------------+--------------------+------------------+------------------+
  432.  | PD0  <-> FSMC_D2  | PE0  <-> FSMC_NBL0 | PF0  <-> FSMC_A0 | PG0 <-> FSMC_A10 |
  433.  | PD1  <-> FSMC_D3  | PE1  <-> FSMC_NBL1 | PF1  <-> FSMC_A1 | PG1 <-> FSMC_A11 |
  434.  | PD4  <-> FSMC_NOE | PE3  <-> FSMC_A19  | PF2  <-> FSMC_A2 | PG2 <-> FSMC_A12 |
  435.  | PD5  <-> FSMC_NWE | PE4  <-> FSMC_A20  | PF3  <-> FSMC_A3 | PG3 <-> FSMC_A13 |
  436.  | PD8  <-> FSMC_D13 | PE7  <-> FSMC_D4   | PF4  <-> FSMC_A4 | PG4 <-> FSMC_A14 |
  437.  | PD9  <-> FSMC_D14 | PE8  <-> FSMC_D5   | PF5  <-> FSMC_A5 | PG5 <-> FSMC_A15 |
  438.  | PD10 <-> FSMC_D15 | PE9  <-> FSMC_D6   | PF12 <-> FSMC_A6 | PG9 <-> FSMC_NE2 |
  439.  | PD11 <-> FSMC_A16 | PE10 <-> FSMC_D7   | PF13 <-> FSMC_A7 |------------------+
  440.  | PD12 <-> FSMC_A17 | PE11 <-> FSMC_D8   | PF14 <-> FSMC_A8 |
  441.  | PD13 <-> FSMC_A18 | PE12 <-> FSMC_D9   | PF15 <-> FSMC_A9 |
  442.  | PD14 <-> FSMC_D0  | PE13 <-> FSMC_D10  |------------------+
  443.  | PD15 <-> FSMC_D1  | PE14 <-> FSMC_D11  |
  444.  |                   | PE15 <-> FSMC_D12  |
  445.  +-------------------+--------------------+
  446. */
  447.    /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
  448.   RCC->AHB1ENR   = 0x00000078;
  449.  
  450.   /* Connect PDx pins to FSMC Alternate function */
  451.   GPIOD->AFR[0]  = 0x00cc00cc;
  452.   GPIOD->AFR[1]  = 0xcc0ccccc;
  453.   /* Configure PDx pins in Alternate function mode */  
  454.   GPIOD->MODER   = 0xaaaa0a0a;
  455.   /* Configure PDx pins speed to 100 MHz */  
  456.   GPIOD->OSPEEDR = 0xffff0f0f;
  457.   /* Configure PDx pins Output type to push-pull */  
  458.   GPIOD->OTYPER  = 0x00000000;
  459.   /* No pull-up, pull-down for PDx pins */
  460.   GPIOD->PUPDR   = 0x00000000;
  461.  
  462.   /* Connect PEx pins to FSMC Alternate function */
  463.   GPIOE->AFR[0]  = 0xc00cc0cc;
  464.   GPIOE->AFR[1]  = 0xcccccccc;
  465.   /* Configure PEx pins in Alternate function mode */
  466.   GPIOE->MODER   = 0xaaaa828a;
  467.   /* Configure PEx pins speed to 100 MHz */
  468.   GPIOE->OSPEEDR = 0xffffc3cf;
  469.   /* Configure PEx pins Output type to push-pull */  
  470.   GPIOE->OTYPER  = 0x00000000;
  471.   /* No pull-up, pull-down for PEx pins */
  472.   GPIOE->PUPDR   = 0x00000000;
  473.  
  474.   /* Connect PFx pins to FSMC Alternate function */
  475.   GPIOF->AFR[0]  = 0x00cccccc;
  476.   GPIOF->AFR[1]  = 0xcccc0000;
  477.   /* Configure PFx pins in Alternate function mode */  
  478.   GPIOF->MODER   = 0xaa000aaa;
  479.   /* Configure PFx pins speed to 100 MHz */
  480.   GPIOF->OSPEEDR = 0xff000fff;
  481.   /* Configure PFx pins Output type to push-pull */  
  482.   GPIOF->OTYPER  = 0x00000000;
  483.   /* No pull-up, pull-down for PFx pins */
  484.   GPIOF->PUPDR   = 0x00000000;
  485.  
  486.   /* Connect PGx pins to FSMC Alternate function */
  487.   GPIOG->AFR[0]  = 0x00cccccc;
  488.   GPIOG->AFR[1]  = 0x000000c0;
  489.   /* Configure PGx pins in Alternate function mode */
  490.   GPIOG->MODER   = 0x00080aaa;
  491.   /* Configure PGx pins speed to 100 MHz */
  492.   GPIOG->OSPEEDR = 0x000c0fff;
  493.   /* Configure PGx pins Output type to push-pull */  
  494.   GPIOG->OTYPER  = 0x00000000;
  495.   /* No pull-up, pull-down for PGx pins */
  496.   GPIOG->PUPDR   = 0x00000000;
  497.  
  498. /*-- FSMC Configuration ------------------------------------------------------*/
  499.   /* Enable the FSMC interface clock */
  500.   RCC->AHB3ENR         = 0x00000001;
  501.  
  502.   /* Configure and enable Bank1_SRAM2 */
  503.   FSMC_Bank1->BTCR[2]  = 0x00001015;
  504.   FSMC_Bank1->BTCR[3]  = 0x00010603;
  505.   FSMC_Bank1E->BWTR[2] = 0x0fffffff;
  506.  /*
  507.   Bank1_SRAM2 is configured as follow:
  508.  
  509.   p.FSMC_AddressSetupTime = 3;
  510.   p.FSMC_AddressHoldTime = 0;
  511.   p.FSMC_DataSetupTime = 6;
  512.   p.FSMC_BusTurnAroundDuration = 1;
  513.   p.FSMC_CLKDivision = 0;
  514.   p.FSMC_DataLatency = 0;
  515.   p.FSMC_AccessMode = FSMC_AccessMode_A;
  516.  
  517.   FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
  518.   FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
  519.   FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_PSRAM;
  520.   FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
  521.   FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
  522.   FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;  
  523.   FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
  524.   FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
  525.   FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
  526.   FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
  527.   FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
  528.   FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
  529.   FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
  530.   FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
  531.   FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
  532. */  
  533. }
  534. #endif /* DATA_IN_ExtSRAM */
  535.  
  536.  
  537. /**
  538.   * @}
  539.   */
  540.  
  541. /**
  542.   * @}
  543.   */
  544.  
  545. /**
  546.   * @}
  547.   */    
  548. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement