source: rtems/bsps/arm/stm32h7/boards/stm/stm32h747i-disco/system_stm32h7xx.c @ a5bde172

Last change on this file since a5bde172 was a5bde172, checked in by Karel Gardas <karel@…>, on 06/01/22 at 11:08:39

bsps/stm32h7: add board C files for stm32h747i-disco BSP

Besides C files for the BSP variant the patch also provides license
clarification on system_stm32h7xx.c file which is provided
in boards/stm/stm32h747i-disco directory.
The files comes from STM32CubeH7 project and references "root directory"
in its license comment and it's not clear where this points out.
Let's add clarification comment about it and also based on it
and resulting license let's add SPDX license identifier.

Sponsored-By: Precidata

  • Property mode set to 100644
File size: 20.1 KB
Line 
1/* SPDX-License-Identifier: BSD-3-Clause */
2/**
3  ******************************************************************************
4  * @file    system_stm32h7xx.c
5  * @author  MCD Application Team
6  * @brief   CMSIS Cortex-Mx Device Peripheral Access Layer System Source File.
7  *
8  *   This file provides two functions and one global variable to be called from
9  *   user application:
10  *      - SystemInit(): This function is called at startup just after reset and
11  *                      before branch to main program. This call is made inside
12  *                      the "startup_stm32h7xx.s" file.
13  *
14  *      - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
15  *                                  by the user application to setup the SysTick
16  *                                  timer or configure other parameters.
17  *                                     
18  *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
19  *                                 be called whenever the core clock is changed
20  *                                 during program execution.
21  *
22  *
23  ******************************************************************************
24  * @attention
25  *
26  * Copyright (c) 2019 STMicroelectronics.
27  * All rights reserved.
28  *
29  * This software is licensed under terms that can be found in the LICENSE file
30  * in the root directory of this software component.
31  * If no LICENSE file comes with this software, it is provided AS-IS.
32  *
33  ******************************************************************************
34  */
35/*
36 * RTEMS committer clarification comment on license above:
37 *
38 * This file comes from STM32CubeH7 project from its Projects
39 * subdirectory. There is Templates subdirectory per every supported
40 * BSP there. The Templates contains the file. In our case the file is
41 * here:
42 * https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Projects/STM32H747I-DISCO/Templates/BootCM4_CM7/Common/Src/system_stm32h7xx.c
43 *
44 * When we go up in the directory tree starting from the file, we find
45 * out that the "root directory" in the sense of license claim above is Templates
46 * directory here:
47 * https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Projects/STM32H747I-DISCO/Templates
48 *
49 * This directory contains LICENSE.md file with a following license text:
50 *
51 * Copyright 2019 STMicroelectronics.
52 * All rights reserved.
53 *
54 * Redistribution and use in source and binary forms, with or without modification,
55 * are permitted provided that the following conditions are met:
56 *
57 * 1. Redistributions of source code must retain the above copyright notice, this
58 * list of conditions and the following disclaimer.
59 *
60 * 2. Redistributions in binary form must reproduce the above copyright notice,
61 * this list of conditions and the following disclaimer in the documentation and/or
62 * other materials provided with the distribution.
63 *
64 * 3. Neither the name of the copyright holder nor the names of its contributors
65 * may be used to endorse or promote products derived from this software without
66 * specific prior written permission.
67 *
68 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
69 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
70 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
71 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
72 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
73 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
74 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
75 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
76 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
77 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78 */
79
80/** @addtogroup CMSIS
81  * @{
82  */
83
84/** @addtogroup stm32h7xx_system
85  * @{
86  */ 
87 
88/** @addtogroup STM32H7xx_System_Private_Includes
89  * @{
90  */
91
92#include "stm32h7xx.h"
93#include <math.h>
94
95#if !defined  (HSE_VALUE)
96#define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
97#endif /* HSE_VALUE */
98
99#if !defined  (CSI_VALUE)
100  #define CSI_VALUE    ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
101#endif /* CSI_VALUE */
102
103#if !defined  (HSI_VALUE)
104  #define HSI_VALUE    ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
105#endif /* HSI_VALUE */
106
107/**
108  * @}
109  */
110
111/** @addtogroup STM32H7xx_System_Private_TypesDefinitions
112  * @{
113  */
114
115/**
116  * @}
117  */
118
119/** @addtogroup STM32H7xx_System_Private_Defines
120  * @{
121  */
122
123/************************* Miscellaneous Configuration ************************/
124/*!< Uncomment the following line if you need to use external SDRAM mounted
125     on DISCO board as data memory  */
126/*#define DATA_IN_ExtSDRAM*/
127#ifdef __rtems__
128#define DATA_IN_ExtSDRAM
129#endif /* __rtems__ */
130/*!< Uncomment the following line if you need to relocate your vector Table in
131     Internal SRAM. */
132/* #define VECT_TAB_SRAM */
133#define VECT_TAB_OFFSET  0x00000000UL       /*!< Vector Table base offset field.
134                                      This value must be a multiple of 0x200. */
135/******************************************************************************/
136
137/**
138  * @}
139  */
140
141/** @addtogroup STM32H7xx_System_Private_Macros
142  * @{
143  */
144
145/**
146  * @}
147  */
148
149/** @addtogroup STM32H7xx_System_Private_Variables
150  * @{
151  */
152  /* This variable is updated in three ways:
153      1) by calling CMSIS function SystemCoreClockUpdate()
154      2) by calling HAL API function HAL_RCC_GetHCLKFreq()
155      3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
156         Note: If you use this function to configure the system clock; then there
157               is no need to call the 2 first functions listed above, since SystemCoreClock
158               variable is updated automatically.
159  */
160  uint32_t SystemCoreClock = 64000000;
161  uint32_t SystemD2Clock = 64000000;
162  const  uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
163
164/**
165  * @}
166  */
167
168/** @addtogroup STM32H7xx_System_Private_FunctionPrototypes
169  * @{
170  */
171#ifndef __rtems__
172#if defined (DATA_IN_ExtSDRAM)
173  static void SystemInit_ExtMemCtl(void);
174#endif /* DATA_IN_ExtSDRAM */
175#endif /* __rtems__ */
176/**
177  * @}
178  */
179
180/** @addtogroup STM32H7xx_System_Private_Functions
181  * @{
182  */
183
184/**
185  * @brief  Setup the microcontroller system
186  *         Initialize the FPU setting, vector table location and External memory
187  *         configuration.
188  * @param  None
189  * @retval None
190  */
191void SystemInit (void)
192{   
193  /* FPU settings ------------------------------------------------------------*/
194  #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
195    SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2)));  /* set CP10 and CP11 Full Access */
196  #endif
197
198  /*SEVONPEND enabled so that an interrupt coming from the CPU(n) interrupt signal is
199    detectable by the CPU after a WFI/WFE instruction.*/
200 SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
201
202#ifdef CORE_CM7
203  /* Reset the RCC clock configuration to the default reset state ------------*/
204  /* Set HSION bit */
205  RCC->CR |= RCC_CR_HSION;
206 
207  /* Reset CFGR register */
208  RCC->CFGR = 0x00000000;
209
210  /* Reset HSEON, CSSON , CSION,RC48ON, CSIKERON PLL1ON, PLL2ON and PLL3ON bits */
211  RCC->CR &= 0xEAF6ED7FU;
212
213  /* Reset D1CFGR register */
214  RCC->D1CFGR = 0x00000000;
215
216  /* Reset D2CFGR register */
217  RCC->D2CFGR = 0x00000000;
218 
219  /* Reset D3CFGR register */
220  RCC->D3CFGR = 0x00000000;
221
222  /* Reset PLLCKSELR register */
223  RCC->PLLCKSELR = 0x00000000;
224
225  /* Reset PLLCFGR register */
226  RCC->PLLCFGR = 0x00000000;
227  /* Reset PLL1DIVR register */
228  RCC->PLL1DIVR = 0x00000000;
229  /* Reset PLL1FRACR register */
230  RCC->PLL1FRACR = 0x00000000;
231
232  /* Reset PLL2DIVR register */
233  RCC->PLL2DIVR = 0x00000000;
234
235  /* Reset PLL2FRACR register */
236 
237  RCC->PLL2FRACR = 0x00000000;
238  /* Reset PLL3DIVR register */
239  RCC->PLL3DIVR = 0x00000000;
240
241  /* Reset PLL3FRACR register */
242  RCC->PLL3FRACR = 0x00000000;
243 
244  /* Reset HSEBYP bit */
245  RCC->CR &= 0xFFFBFFFFU;
246
247  /* Disable all interrupts */
248  RCC->CIER = 0x00000000;
249
250  /* Enable CortexM7 HSEM EXTI line (line 78)*/
251  EXTI_D2->EMR3 |= 0x4000UL; 
252
253  /* Change  the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */
254  if((DBGMCU->IDCODE & 0xFFFF0000U) < 0x20000000U)
255  {
256    /* if stm32h7 revY*/
257    /* Change  the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */
258    *((__IO uint32_t*)0x51008108) = 0x00000001U;
259  }
260 
261
262/*
263   * Disable the FMC bank1 (enabled after reset).
264   * This, prevents CPU speculation access on this bank which blocks the use of FMC during
265   * 24us. During this time the others FMC master (such as LTDC) cannot use it!
266   */
267  FMC_Bank1_R->BTCR[0] = 0x000030D2;
268
269#if defined (DATA_IN_ExtSDRAM)
270  SystemInit_ExtMemCtl();
271#endif /* DATA_IN_ExtSDRAM */
272 
273#endif /* CORE_CM7*/
274
275#ifdef CORE_CM4
276
277  /* Configure the Vector Table location add offset address ------------------*/
278#ifdef VECT_TAB_SRAM
279  SCB->VTOR = D2_AXISRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
280#else
281  SCB->VTOR = FLASH_BANK2_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
282#endif 
283
284#else
285#ifdef CORE_CM7
286
287  /* Configure the Vector Table location add offset address ------------------*/
288#ifdef VECT_TAB_SRAM
289  SCB->VTOR = D1_AXISRAM_BASE  | VECT_TAB_OFFSET;       /* Vector Table Relocation in Internal SRAM */
290#else
291  SCB->VTOR = FLASH_BANK1_BASE | VECT_TAB_OFFSET;       /* Vector Table Relocation in Internal FLASH */
292#endif 
293
294#else
295#error Please #define CORE_CM4 or CORE_CM7
296#endif                       
297#endif
298
299}
300
301/**
302   * @brief  Update SystemCoreClock variable according to Clock Register Values.
303  *         The SystemCoreClock variable contains the core clock , it can
304  *         be used by the user application to setup the SysTick timer or configure
305  *         other parameters.
306  *           
307  * @note   Each time the core clock changes, this function must be called
308  *         to update SystemCoreClock variable value. Otherwise, any configuration
309  *         based on this variable will be incorrect.         
310  *     
311  * @note   - The system frequency computed by this function is not the real
312  *           frequency in the chip. It is calculated based on the predefined
313  *           constant and the selected clock source:
314  *             
315  *           - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*)                                 
316  *           - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**)
317  *           - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***)
318  *           - If SYSCLK source is PLL, SystemCoreClock will contain the CSI_VALUE(*),
319  *             HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors.
320  *
321  *         (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value
322  *             4 MHz) but the real value may vary depending on the variations
323  *             in voltage and temperature.       
324  *         (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value
325  *             64 MHz) but the real value may vary depending on the variations
326  *             in voltage and temperature.   
327  *   
328  *         (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value
329  *              25 MHz), user has to ensure that HSE_VALUE is same as the real
330  *              frequency of the crystal used. Otherwise, this function may
331  *              have wrong result.
332  *               
333  *         - The result of this function could be not correct when using fractional
334  *           value for HSE crystal.
335  * @param  None
336  * @retval None
337  */
338void SystemCoreClockUpdate (void)
339{
340  uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp;
341  uint32_t common_system_clock;
342  float_t fracn1, pllvco;
343
344  /* Get SYSCLK source -------------------------------------------------------*/
345
346  switch (RCC->CFGR & RCC_CFGR_SWS)
347  {
348  case RCC_CFGR_SWS_HSI:  /* HSI used as system clock source */
349    common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
350    break;
351
352  case RCC_CFGR_SWS_CSI:  /* CSI used as system clock  source */
353    common_system_clock = CSI_VALUE;
354    break;
355
356  case RCC_CFGR_SWS_HSE:  /* HSE used as system clock  source */
357    common_system_clock = HSE_VALUE;
358    break;
359
360  case RCC_CFGR_SWS_PLL1:  /* PLL1 used as system clock  source */
361
362    /* PLL_VCO = (HSE_VALUE or HSI_VALUE or CSI_VALUE/ PLLM) * PLLN
363    SYSCLK = PLL_VCO / PLLR
364    */
365    pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC);
366    pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4)  ;
367    pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos);
368    fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3));
369
370    if (pllm != 0U)
371    {
372      switch (pllsource)
373      {
374        case RCC_PLLCKSELR_PLLSRC_HSI:  /* HSI used as PLL clock source */
375
376        hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ;
377        pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
378
379        break;
380
381        case RCC_PLLCKSELR_PLLSRC_CSI:  /* CSI used as PLL clock source */
382          pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
383        break;
384
385        case RCC_PLLCKSELR_PLLSRC_HSE:  /* HSE used as PLL clock source */
386          pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
387        break;
388
389      default:
390          pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
391        break;
392      }
393      pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ;
394      common_system_clock =  (uint32_t)(float_t)(pllvco/(float_t)pllp);
395    }
396    else
397    {
398      common_system_clock = 0U;
399    }
400    break;
401
402  default:
403    common_system_clock = CSI_VALUE;
404    break;
405  }
406
407  /* Compute SystemClock frequency --------------------------------------------------*/
408  tmp = D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos];
409
410  /* common_system_clock frequency : CM7 CPU frequency  */
411  common_system_clock >>= tmp;
412
413  /* SystemD2Clock frequency : CM4 CPU, AXI and AHBs Clock frequency  */
414  SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU));
415
416#if defined(DUAL_CORE) && defined(CORE_CM4)
417  SystemCoreClock = SystemD2Clock;
418#else
419  SystemCoreClock = common_system_clock;
420#endif /* DUAL_CORE && CORE_CM4 */
421}
422#if defined (DATA_IN_ExtSDRAM)
423/**
424  * @brief  Setup the external memory controller.
425  *         Called in startup_stm32h7xx.s before jump to main.
426  *         This function configures the external memories SDRAM
427  *         This SDRAM will be used as program data memory (including heap and stack).
428  * @param  None
429  * @retval None
430  */
431void SystemInit_ExtMemCtl(void)
432{
433  __IO uint32_t tmp = 0;
434  register uint32_t tmpreg = 0, timeout = 0xFFFF;
435  register __IO uint32_t index;
436
437  /* Enable GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
438      clock */
439  RCC->AHB4ENR |= 0x000001F8;
440 
441  /* Delay after an RCC peripheral clock enabling */
442  tmp = READ_BIT(RCC->AHB4ENR, RCC_AHB4ENR_GPIOEEN);
443 
444  /* Connect PDx pins to FMC Alternate function */
445  GPIOD->AFR[0]  = 0x000000CC;
446  GPIOD->AFR[1]  = 0xCC000CCC;
447  /* Configure PDx pins in Alternate function mode */ 
448  GPIOD->MODER   = 0xAFEAFFFA;
449  /* Configure PDx pins speed to 100 MHz */ 
450  GPIOD->OSPEEDR = 0xF03F000F;
451  /* Configure PDx pins Output type to push-pull */ 
452  GPIOD->OTYPER  = 0x00000000;
453  /* Configure PDx pins in Pull-up */
454  GPIOD->PUPDR   = 0x50150005;
455   
456  /* Connect PEx pins to FMC Alternate function */
457  GPIOE->AFR[0]  = 0xC00000CC;
458  GPIOE->AFR[1]  = 0xCCCCCCCC;
459  /* Configure PEx pins in Alternate function mode */
460  GPIOE->MODER   = 0xAAAABFFA;
461  /* Configure PEx pins speed to 100 MHz */
462  GPIOE->OSPEEDR = 0xFFFFC00F;
463  /* Configure PEx pins Output type to push-pull */ 
464  GPIOE->OTYPER  = 0x00000000;
465  /* Configure PEx pins in Pull-up */
466  GPIOE->PUPDR   = 0x55554005;
467 
468  /* Connect PFx pins to FMC Alternate function */
469  GPIOF->AFR[0]  = 0x00CCCCCC;
470  GPIOF->AFR[1]  = 0xCCCCC000;
471  /* Configure PFx pins in Alternate function mode */   
472  GPIOF->MODER   = 0xAABFFAAA;
473  /* Configure PFx pins speed to 100 MHz */
474  GPIOF->OSPEEDR = 0xFFC00FFF;
475  /* Configure PFx pins Output type to push-pull */ 
476  GPIOF->OTYPER  = 0x00000000;
477  /* Configure PFx pins in Pull-up */
478  GPIOF->PUPDR   = 0x55400555;
479 
480  /* Connect PGx pins to FMC Alternate function */
481  GPIOG->AFR[0]  = 0x00CCCCCC;
482  GPIOG->AFR[1]  = 0xC000000C;
483  /* Configure PGx pins in Alternate function mode */
484  GPIOG->MODER   = 0xBFFEFAAA;
485 /* Configure PGx pins speed to 100 MHz */
486  GPIOG->OSPEEDR = 0xC0030FFF;
487  /* Configure PGx pins Output type to push-pull */ 
488  GPIOG->OTYPER  = 0x00000000;
489  /* Configure PGx pins in Pull-up */
490  GPIOG->PUPDR   = 0x40010555;
491 
492  /* Connect PHx pins to FMC Alternate function */
493  GPIOH->AFR[0]  = 0xCCC00000;
494  GPIOH->AFR[1]  = 0xCCCCCCCC;
495  /* Configure PHx pins in Alternate function mode */
496  GPIOH->MODER   = 0xAAAAABFF;
497  /* Configure PHx pins speed to 100 MHz */
498  GPIOH->OSPEEDR = 0xFFFFFC00;
499  /* Configure PHx pins Output type to push-pull */ 
500  GPIOH->OTYPER  = 0x00000000;
501  /* Configure PHx pins in Pull-up */
502  GPIOH->PUPDR   = 0x55555400;
503 
504  /* Connect PIx pins to FMC Alternate function */
505  GPIOI->AFR[0]  = 0xCCCCCCCC;
506  GPIOI->AFR[1]  = 0x00000CC0;
507  /* Configure PIx pins in Alternate function mode */
508  GPIOI->MODER   = 0xFFEBAAAA;
509  /* Configure PIx pins speed to 100 MHz */
510  GPIOI->OSPEEDR = 0x003CFFFF;
511  /* Configure PIx pins Output type to push-pull */ 
512  GPIOI->OTYPER  = 0x00000000;
513  /* Configure PIx pins in Pull-up */
514  GPIOI->PUPDR   = 0x00145555;
515 
516/*-- FMC Configuration ------------------------------------------------------*/
517  /* Enable the FMC interface clock */
518  (RCC->AHB3ENR |= (RCC_AHB3ENR_FMCEN));
519  /*SDRAM Timing and access interface configuration*/
520  /*LoadToActiveDelay  = 2
521    ExitSelfRefreshDelay = 6
522    SelfRefreshTime      = 4
523    RowCycleDelay        = 6
524    WriteRecoveryTime    = 2
525    RPDelay              = 2
526    RCDDelay             = 2
527    SDBank             = FMC_SDRAM_BANK2
528    ColumnBitsNumber   = FMC_SDRAM_COLUMN_BITS_NUM_9
529    RowBitsNumber      = FMC_SDRAM_ROW_BITS_NUM_12
530    MemoryDataWidth    = FMC_SDRAM_MEM_BUS_WIDTH_32
531    InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4
532    CASLatency         = FMC_SDRAM_CAS_LATENCY_2
533    WriteProtection    = FMC_SDRAM_WRITE_PROTECTION_DISABLE
534    SDClockPeriod      = FMC_SDRAM_CLOCK_PERIOD_2
535    ReadBurst          = FMC_SDRAM_RBURST_ENABLE
536    ReadPipeDelay      = FMC_SDRAM_RPIPE_DELAY_0*/
537 
538  FMC_Bank5_6_R->SDCR[0] = 0x00001800;
539  FMC_Bank5_6_R->SDCR[1] = 0x00000165;
540  FMC_Bank5_6_R->SDTR[0] = 0x00105000;
541  FMC_Bank5_6_R->SDTR[1] = 0x01010351;
542
543  /* SDRAM initialization sequence */
544  /* Clock enable command */
545  FMC_Bank5_6_R->SDCMR = 0x00000009;
546  tmpreg = FMC_Bank5_6_R->SDSR & 0x00000020;
547  while((tmpreg != 0) && (timeout-- > 0))
548  {
549    tmpreg = FMC_Bank5_6_R->SDSR & 0x00000020;
550  }
551
552  /* Delay */
553  for (index = 0; index<1000; index++);
554 
555  /* PALL command */
556    FMC_Bank5_6_R->SDCMR = 0x0000000A; 
557  timeout = 0xFFFF;
558  while((tmpreg != 0) && (timeout-- > 0))
559  {
560    tmpreg = FMC_Bank5_6_R->SDSR & 0x00000020;
561  }
562 
563  FMC_Bank5_6_R->SDCMR = 0x000000EB;
564  timeout = 0xFFFF;
565  while((tmpreg != 0) && (timeout-- > 0))
566  {
567    tmpreg = FMC_Bank5_6_R->SDSR & 0x00000020;
568  }
569
570  FMC_Bank5_6_R->SDCMR = 0x0004400C;
571  timeout = 0xFFFF;
572  while((tmpreg != 0) && (timeout-- > 0))
573  {
574    tmpreg = FMC_Bank5_6_R->SDSR & 0x00000020;
575  }
576  /* Set refresh count */
577  tmpreg = FMC_Bank5_6_R->SDRTR;
578  FMC_Bank5_6_R->SDRTR = (tmpreg | (0x00000603<<1));
579
580  /* Disable write protection */
581  tmpreg = FMC_Bank5_6_R->SDCR[1];
582  FMC_Bank5_6_R->SDCR[1] = (tmpreg & 0xFFFFFDFF);
583
584   /*FMC controller Enable*/
585  FMC_Bank1_R->BTCR[0]  |= 0x80000000;
586
587  (void)(tmp);
588}
589#endif /* DATA_IN_ExtSDRAM */
590
591 
592/**
593  * @}
594  */
595
596/**
597  * @}
598  */
599
600/**
601  * @}
602  */
Note: See TracBrowser for help on using the repository browser.