system_stm32f4xx.c 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395
  1. /**
  2. ******************************************************************************
  3. * @file system_stm32f4xx.c
  4. * @author MCD Application Team
  5. * @version V1.8.0
  6. * @date 09-November-2016
  7. * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
  8. * This file contains the system clock configuration for STM32F4xx devices.
  9. *
  10. * 1. This file provides two functions and one global variable to be called from
  11. * user application:
  12. * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
  13. * and Divider factors, AHB/APBx prescalers and Flash settings),
  14. * depending on the configuration made in the clock xls tool.
  15. * This function is called at startup just after reset and
  16. * before branch to main program. This call is made inside
  17. * the "startup_stm32f4xx.s" file.
  18. *
  19. * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
  20. * by the user application to setup the SysTick
  21. * timer or configure other parameters.
  22. *
  23. * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
  24. * be called whenever the core clock is changed
  25. * during program execution.
  26. *
  27. * 2. After each device reset the HSI (16 MHz) is used as system clock source.
  28. * Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to
  29. * configure the system clock before to branch to main program.
  30. *
  31. * 3. If the system clock source selected by user fails to startup, the SystemInit()
  32. * function will do nothing and HSI still used as system clock source. User can
  33. * add some code to deal with this issue inside the SetSysClock() function.
  34. *
  35. * 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define
  36. * in "stm32f4xx.h" file. When HSE is used as system clock source, directly or
  37. * through PLL, and you are using different crystal you have to adapt the HSE
  38. * value to your own configuration.
  39. *
  40. * 5. This file configures the system clock as follows:
  41. *=============================================================================
  42. *=============================================================================
  43. * Supported STM32F40xxx/41xxx devices
  44. *-----------------------------------------------------------------------------
  45. * System Clock source | PLL (HSE)
  46. *-----------------------------------------------------------------------------
  47. * SYSCLK(Hz) | 168000000
  48. *-----------------------------------------------------------------------------
  49. * HCLK(Hz) | 168000000
  50. *-----------------------------------------------------------------------------
  51. * AHB Prescaler | 1
  52. *-----------------------------------------------------------------------------
  53. * APB1 Prescaler | 4
  54. *-----------------------------------------------------------------------------
  55. * APB2 Prescaler | 2
  56. *-----------------------------------------------------------------------------
  57. * HSE Frequency(Hz) | 25000000
  58. *-----------------------------------------------------------------------------
  59. * PLL_M | 25
  60. *-----------------------------------------------------------------------------
  61. * PLL_N | 336
  62. *-----------------------------------------------------------------------------
  63. * PLL_P | 2
  64. *-----------------------------------------------------------------------------
  65. * PLL_Q | 7
  66. *-----------------------------------------------------------------------------
  67. * PLLI2S_N | NA
  68. *-----------------------------------------------------------------------------
  69. * PLLI2S_R | NA
  70. *-----------------------------------------------------------------------------
  71. * I2S input clock | NA
  72. *-----------------------------------------------------------------------------
  73. * VDD(V) | 3.3
  74. *-----------------------------------------------------------------------------
  75. * Main regulator output voltage | Scale1 mode
  76. *-----------------------------------------------------------------------------
  77. * Flash Latency(WS) | 5
  78. *-----------------------------------------------------------------------------
  79. * Prefetch Buffer | ON
  80. *-----------------------------------------------------------------------------
  81. * Instruction cache | ON
  82. *-----------------------------------------------------------------------------
  83. * Data cache | ON
  84. *-----------------------------------------------------------------------------
  85. * Require 48MHz for USB OTG FS, | Disabled
  86. * SDIO and RNG clock |
  87. *-----------------------------------------------------------------------------
  88. *=============================================================================
  89. *=============================================================================
  90. * Supported STM32F42xxx/43xxx devices
  91. *-----------------------------------------------------------------------------
  92. * System Clock source | PLL (HSE)
  93. *-----------------------------------------------------------------------------
  94. * SYSCLK(Hz) | 180000000
  95. *-----------------------------------------------------------------------------
  96. * HCLK(Hz) | 180000000
  97. *-----------------------------------------------------------------------------
  98. * AHB Prescaler | 1
  99. *-----------------------------------------------------------------------------
  100. * APB1 Prescaler | 4
  101. *-----------------------------------------------------------------------------
  102. * APB2 Prescaler | 2
  103. *-----------------------------------------------------------------------------
  104. * HSE Frequency(Hz) | 25000000
  105. *-----------------------------------------------------------------------------
  106. * PLL_M | 25
  107. *-----------------------------------------------------------------------------
  108. * PLL_N | 360
  109. *-----------------------------------------------------------------------------
  110. * PLL_P | 2
  111. *-----------------------------------------------------------------------------
  112. * PLL_Q | 7
  113. *-----------------------------------------------------------------------------
  114. * PLLI2S_N | NA
  115. *-----------------------------------------------------------------------------
  116. * PLLI2S_R | NA
  117. *-----------------------------------------------------------------------------
  118. * I2S input clock | NA
  119. *-----------------------------------------------------------------------------
  120. * VDD(V) | 3.3
  121. *-----------------------------------------------------------------------------
  122. * Main regulator output voltage | Scale1 mode
  123. *-----------------------------------------------------------------------------
  124. * Flash Latency(WS) | 5
  125. *-----------------------------------------------------------------------------
  126. * Prefetch Buffer | ON
  127. *-----------------------------------------------------------------------------
  128. * Instruction cache | ON
  129. *-----------------------------------------------------------------------------
  130. * Data cache | ON
  131. *-----------------------------------------------------------------------------
  132. * Require 48MHz for USB OTG FS, | Disabled
  133. * SDIO and RNG clock |
  134. *-----------------------------------------------------------------------------
  135. *=============================================================================
  136. *=============================================================================
  137. * Supported STM32F401xx devices
  138. *-----------------------------------------------------------------------------
  139. * System Clock source | PLL (HSE)
  140. *-----------------------------------------------------------------------------
  141. * SYSCLK(Hz) | 84000000
  142. *-----------------------------------------------------------------------------
  143. * HCLK(Hz) | 84000000
  144. *-----------------------------------------------------------------------------
  145. * AHB Prescaler | 1
  146. *-----------------------------------------------------------------------------
  147. * APB1 Prescaler | 2
  148. *-----------------------------------------------------------------------------
  149. * APB2 Prescaler | 1
  150. *-----------------------------------------------------------------------------
  151. * HSE Frequency(Hz) | 25000000
  152. *-----------------------------------------------------------------------------
  153. * PLL_M | 25
  154. *-----------------------------------------------------------------------------
  155. * PLL_N | 336
  156. *-----------------------------------------------------------------------------
  157. * PLL_P | 4
  158. *-----------------------------------------------------------------------------
  159. * PLL_Q | 7
  160. *-----------------------------------------------------------------------------
  161. * PLLI2S_N | NA
  162. *-----------------------------------------------------------------------------
  163. * PLLI2S_R | NA
  164. *-----------------------------------------------------------------------------
  165. * I2S input clock | NA
  166. *-----------------------------------------------------------------------------
  167. * VDD(V) | 3.3
  168. *-----------------------------------------------------------------------------
  169. * Main regulator output voltage | Scale1 mode
  170. *-----------------------------------------------------------------------------
  171. * Flash Latency(WS) | 2
  172. *-----------------------------------------------------------------------------
  173. * Prefetch Buffer | ON
  174. *-----------------------------------------------------------------------------
  175. * Instruction cache | ON
  176. *-----------------------------------------------------------------------------
  177. * Data cache | ON
  178. *-----------------------------------------------------------------------------
  179. * Require 48MHz for USB OTG FS, | Disabled
  180. * SDIO and RNG clock |
  181. *-----------------------------------------------------------------------------
  182. *=============================================================================
  183. *=============================================================================
  184. * Supported STM32F411xx/STM32F410xx devices
  185. *-----------------------------------------------------------------------------
  186. * System Clock source | PLL (HSI)
  187. *-----------------------------------------------------------------------------
  188. * SYSCLK(Hz) | 100000000
  189. *-----------------------------------------------------------------------------
  190. * HCLK(Hz) | 100000000
  191. *-----------------------------------------------------------------------------
  192. * AHB Prescaler | 1
  193. *-----------------------------------------------------------------------------
  194. * APB1 Prescaler | 2
  195. *-----------------------------------------------------------------------------
  196. * APB2 Prescaler | 1
  197. *-----------------------------------------------------------------------------
  198. * HSI Frequency(Hz) | 16000000
  199. *-----------------------------------------------------------------------------
  200. * PLL_M | 16
  201. *-----------------------------------------------------------------------------
  202. * PLL_N | 400
  203. *-----------------------------------------------------------------------------
  204. * PLL_P | 4
  205. *-----------------------------------------------------------------------------
  206. * PLL_Q | 7
  207. *-----------------------------------------------------------------------------
  208. * PLLI2S_N | NA
  209. *-----------------------------------------------------------------------------
  210. * PLLI2S_R | NA
  211. *-----------------------------------------------------------------------------
  212. * I2S input clock | NA
  213. *-----------------------------------------------------------------------------
  214. * VDD(V) | 3.3
  215. *-----------------------------------------------------------------------------
  216. * Main regulator output voltage | Scale1 mode
  217. *-----------------------------------------------------------------------------
  218. * Flash Latency(WS) | 3
  219. *-----------------------------------------------------------------------------
  220. * Prefetch Buffer | ON
  221. *-----------------------------------------------------------------------------
  222. * Instruction cache | ON
  223. *-----------------------------------------------------------------------------
  224. * Data cache | ON
  225. *-----------------------------------------------------------------------------
  226. * Require 48MHz for USB OTG FS, | Disabled
  227. * SDIO and RNG clock |
  228. *-----------------------------------------------------------------------------
  229. *=============================================================================
  230. *=============================================================================
  231. * Supported STM32F446xx devices
  232. *-----------------------------------------------------------------------------
  233. * System Clock source | PLL (HSE)
  234. *-----------------------------------------------------------------------------
  235. * SYSCLK(Hz) | 180000000
  236. *-----------------------------------------------------------------------------
  237. * HCLK(Hz) | 180000000
  238. *-----------------------------------------------------------------------------
  239. * AHB Prescaler | 1
  240. *-----------------------------------------------------------------------------
  241. * APB1 Prescaler | 4
  242. *-----------------------------------------------------------------------------
  243. * APB2 Prescaler | 2
  244. *-----------------------------------------------------------------------------
  245. * HSE Frequency(Hz) | 8000000
  246. *-----------------------------------------------------------------------------
  247. * PLL_M | 8
  248. *-----------------------------------------------------------------------------
  249. * PLL_N | 360
  250. *-----------------------------------------------------------------------------
  251. * PLL_P | 2
  252. *-----------------------------------------------------------------------------
  253. * PLL_Q | 7
  254. *-----------------------------------------------------------------------------
  255. * PLL_R | NA
  256. *-----------------------------------------------------------------------------
  257. * PLLI2S_M | NA
  258. *-----------------------------------------------------------------------------
  259. * PLLI2S_N | NA
  260. *-----------------------------------------------------------------------------
  261. * PLLI2S_P | NA
  262. *-----------------------------------------------------------------------------
  263. * PLLI2S_Q | NA
  264. *-----------------------------------------------------------------------------
  265. * PLLI2S_R | NA
  266. *-----------------------------------------------------------------------------
  267. * I2S input clock | NA
  268. *-----------------------------------------------------------------------------
  269. * VDD(V) | 3.3
  270. *-----------------------------------------------------------------------------
  271. * Main regulator output voltage | Scale1 mode
  272. *-----------------------------------------------------------------------------
  273. * Flash Latency(WS) | 5
  274. *-----------------------------------------------------------------------------
  275. * Prefetch Buffer | ON
  276. *-----------------------------------------------------------------------------
  277. * Instruction cache | ON
  278. *-----------------------------------------------------------------------------
  279. * Data cache | ON
  280. *-----------------------------------------------------------------------------
  281. * Require 48MHz for USB OTG FS, | Disabled
  282. * SDIO and RNG clock |
  283. *-----------------------------------------------------------------------------
  284. *=============================================================================
  285. ******************************************************************************
  286. * @attention
  287. *
  288. * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
  289. *
  290. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  291. * You may not use this file except in compliance with the License.
  292. * You may obtain a copy of the License at:
  293. *
  294. * http://www.st.com/software_license_agreement_liberty_v2
  295. *
  296. * Unless required by applicable law or agreed to in writing, software
  297. * distributed under the License is distributed on an "AS IS" BASIS,
  298. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  299. * See the License for the specific language governing permissions and
  300. * limitations under the License.
  301. *
  302. ******************************************************************************
  303. */
  304. /** @addtogroup CMSIS
  305. * @{
  306. */
  307. /** @addtogroup stm32f4xx_system
  308. * @{
  309. */
  310. /** @addtogroup STM32F4xx_System_Private_Includes
  311. * @{
  312. */
  313. #include "stm32f4xx.h"
  314. /**
  315. * @}
  316. */
  317. /** @addtogroup STM32F4xx_System_Private_TypesDefinitions
  318. * @{
  319. */
  320. /**
  321. * @}
  322. */
  323. /** @addtogroup STM32F4xx_System_Private_Defines
  324. * @{
  325. */
  326. /************************* Miscellaneous Configuration ************************/
  327. /*!< Uncomment the following line if you need to use external SRAM or SDRAM mounted
  328. on STM324xG_EVAL/STM324x7I_EVAL/STM324x9I_EVAL boards as data memory */
  329. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx) || defined(STM32F413_423xx)
  330. /* #define DATA_IN_ExtSRAM */
  331. #endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F469_479xx || STM32F413_423xx */
  332. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  333. /* #define DATA_IN_ExtSDRAM */
  334. #endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  335. #if defined(STM32F410xx) || defined(STM32F411xE)
  336. /*!< Uncomment the following line if you need to clock the STM32F410xx/STM32F411xE by HSE Bypass
  337. through STLINK MCO pin of STM32F103 microcontroller. The frequency cannot be changed
  338. and is fixed at 8 MHz.
  339. Hardware configuration needed for Nucleo Board:
  340. – SB54, SB55 OFF
  341. – R35 removed
  342. – SB16, SB50 ON */
  343. /* #define USE_HSE_BYPASS */
  344. #if defined(USE_HSE_BYPASS)
  345. #define HSE_BYPASS_INPUT_FREQUENCY 8000000
  346. #endif /* USE_HSE_BYPASS */
  347. #endif /* STM32F410xx || STM32F411xE */
  348. /*!< Uncomment the following line if you need to relocate your vector Table in
  349. Internal SRAM. */
  350. /* #define VECT_TAB_SRAM */
  351. #define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
  352. This value must be a multiple of 0x200. */
  353. /******************************************************************************/
  354. /************************* PLL Parameters *************************************/
  355. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F469_479xx)
  356. /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
  357. #define PLL_M 8
  358. #elif defined(STM32F412xG) || defined(STM32F413_423xx) || defined (STM32F446xx)
  359. #define PLL_M 8
  360. #elif defined (STM32F410xx) || defined (STM32F411xE)
  361. #if defined(USE_HSE_BYPASS)
  362. #define PLL_M 8
  363. #else /* !USE_HSE_BYPASS */
  364. #define PLL_M 16
  365. #endif /* USE_HSE_BYPASS */
  366. #else
  367. #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F469_479xx */
  368. /* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */
  369. #define PLL_Q 7
  370. #if defined(STM32F446xx)
  371. /* PLL division factor for I2S, SAI, SYSTEM and SPDIF: Clock = PLL_VCO / PLLR */
  372. #define PLL_R 7
  373. #elif defined(STM32F412xG) || defined(STM32F413_423xx)
  374. #define PLL_R 2
  375. #else
  376. #endif /* STM32F446xx */
  377. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  378. #define PLL_N 360
  379. /* SYSCLK = PLL_VCO / PLL_P */
  380. #define PLL_P 2
  381. #endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  382. #if defined (STM32F40_41xxx)
  383. #define PLL_N 336
  384. /* SYSCLK = PLL_VCO / PLL_P */
  385. #define PLL_P 2
  386. #endif /* STM32F40_41xxx */
  387. #if defined(STM32F401xx)
  388. #define PLL_N 336
  389. /* SYSCLK = PLL_VCO / PLL_P */
  390. #define PLL_P 4
  391. #endif /* STM32F401xx */
  392. #if defined(STM32F410xx) || defined(STM32F411xE) || defined(STM32F412xG) || defined(STM32F413_423xx)
  393. #define PLL_N 400
  394. /* SYSCLK = PLL_VCO / PLL_P */
  395. #define PLL_P 4
  396. #endif /* STM32F410xx || STM32F411xE || STM32F412xG || STM32F413_423xx */
  397. /******************************************************************************/
  398. /**
  399. * @}
  400. */
  401. /** @addtogroup STM32F4xx_System_Private_Macros
  402. * @{
  403. */
  404. /**
  405. * @}
  406. */
  407. /** @addtogroup STM32F4xx_System_Private_Variables
  408. * @{
  409. */
  410. #if defined(STM32F40_41xxx)
  411. uint32_t SystemCoreClock = 168000000;
  412. #endif /* STM32F40_41xxx */
  413. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  414. uint32_t SystemCoreClock = 180000000;
  415. #endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  416. #if defined(STM32F401xx)
  417. uint32_t SystemCoreClock = 84000000;
  418. #endif /* STM32F401xx */
  419. #if defined(STM32F410xx) || defined(STM32F411xE) || defined(STM32F412xG) || defined(STM32F413_423xx)
  420. uint32_t SystemCoreClock = 100000000;
  421. #endif /* STM32F410xx || STM32F401xE || STM32F412xG || STM32F413_423xx */
  422. __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
  423. /**
  424. * @}
  425. */
  426. /** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
  427. * @{
  428. */
  429. static void SetSysClock(void);
  430. #if defined(DATA_IN_ExtSRAM) || defined(DATA_IN_ExtSDRAM)
  431. static void SystemInit_ExtMemCtl(void);
  432. #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
  433. /**
  434. * @}
  435. */
  436. /** @addtogroup STM32F4xx_System_Private_Functions
  437. * @{
  438. */
  439. /**
  440. * @brief Setup the microcontroller system
  441. * Initialize the Embedded Flash Interface, the PLL and update the
  442. * SystemFrequency variable.
  443. * @param None
  444. * @retval None
  445. */
  446. void SystemInit(void)
  447. {
  448. /* FPU settings ------------------------------------------------------------*/
  449. #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
  450. SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
  451. #endif
  452. /* Reset the RCC clock configuration to the default reset state ------------*/
  453. /* Set HSION bit */
  454. RCC->CR |= (uint32_t)0x00000001;
  455. /* Reset CFGR register */
  456. RCC->CFGR = 0x00000000;
  457. /* Reset HSEON, CSSON and PLLON bits */
  458. RCC->CR &= (uint32_t)0xFEF6FFFF;
  459. /* Reset PLLCFGR register */
  460. RCC->PLLCFGR = 0x24003010;
  461. /* Reset HSEBYP bit */
  462. RCC->CR &= (uint32_t)0xFFFBFFFF;
  463. /* Disable all interrupts */
  464. RCC->CIR = 0x00000000;
  465. #if defined(DATA_IN_ExtSRAM) || defined(DATA_IN_ExtSDRAM)
  466. SystemInit_ExtMemCtl();
  467. #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
  468. /* Configure the System clock source, PLL Multiplier and Divider factors,
  469. AHB/APBx prescalers and Flash settings ----------------------------------*/
  470. SetSysClock();
  471. /* Configure the Vector Table location add offset address ------------------*/
  472. #ifdef VECT_TAB_SRAM
  473. SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
  474. #else
  475. SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
  476. #endif
  477. }
  478. /**
  479. * @brief Update SystemCoreClock variable according to Clock Register Values.
  480. * The SystemCoreClock variable contains the core clock (HCLK), it can
  481. * be used by the user application to setup the SysTick timer or configure
  482. * other parameters.
  483. *
  484. * @note Each time the core clock (HCLK) changes, this function must be called
  485. * to update SystemCoreClock variable value. Otherwise, any configuration
  486. * based on this variable will be incorrect.
  487. *
  488. * @note - The system frequency computed by this function is not the real
  489. * frequency in the chip. It is calculated based on the predefined
  490. * constant and the selected clock source:
  491. *
  492. * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
  493. *
  494. * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
  495. *
  496. * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
  497. * or HSI_VALUE(*) multiplied/divided by the PLL factors.
  498. *
  499. * (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value
  500. * 16 MHz) but the real value may vary depending on the variations
  501. * in voltage and temperature.
  502. *
  503. * (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value
  504. * 25 MHz), user has to ensure that HSE_VALUE is same as the real
  505. * frequency of the crystal used. Otherwise, this function may
  506. * have wrong result.
  507. *
  508. * - The result of this function could be not correct when using fractional
  509. * value for HSE crystal.
  510. *
  511. * @param None
  512. * @retval None
  513. */
  514. void SystemCoreClockUpdate(void)
  515. {
  516. uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
  517. #if defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx)
  518. uint32_t pllr = 2;
  519. #endif /* STM32F412xG || STM32F413_423xx || STM32F446xx */
  520. /* Get SYSCLK source -------------------------------------------------------*/
  521. tmp = RCC->CFGR & RCC_CFGR_SWS;
  522. switch (tmp)
  523. {
  524. case 0x00: /* HSI used as system clock source */
  525. SystemCoreClock = HSI_VALUE;
  526. break;
  527. case 0x04: /* HSE used as system clock source */
  528. SystemCoreClock = HSE_VALUE;
  529. break;
  530. case 0x08: /* PLL P used as system clock source */
  531. /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
  532. SYSCLK = PLL_VCO / PLL_P
  533. */
  534. pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
  535. pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
  536. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  537. if (pllsource != 0)
  538. {
  539. /* HSE used as PLL clock source */
  540. pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  541. }
  542. else
  543. {
  544. /* HSI used as PLL clock source */
  545. pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  546. }
  547. #elif defined(STM32F410xx) || defined(STM32F411xE)
  548. #if defined(USE_HSE_BYPASS)
  549. if (pllsource != 0)
  550. {
  551. /* HSE used as PLL clock source */
  552. pllvco = (HSE_BYPASS_INPUT_FREQUENCY / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  553. }
  554. #else
  555. if (pllsource == 0)
  556. {
  557. /* HSI used as PLL clock source */
  558. pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  559. }
  560. #endif /* USE_HSE_BYPASS */
  561. #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F412xG || STM32F413_423xx || STM32F446xx || STM32F469_479xx */
  562. pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
  563. SystemCoreClock = pllvco/pllp;
  564. break;
  565. #if defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx)
  566. case 0x0C: /* PLL R used as system clock source */
  567. /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
  568. SYSCLK = PLL_VCO / PLL_R
  569. */
  570. pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
  571. pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
  572. if (pllsource != 0)
  573. {
  574. /* HSE used as PLL clock source */
  575. pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  576. }
  577. else
  578. {
  579. /* HSI used as PLL clock source */
  580. pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  581. }
  582. pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >>28) + 1 ) *2;
  583. SystemCoreClock = pllvco/pllr;
  584. break;
  585. #endif /* STM32F412xG || STM32F413_423xx || STM32F446xx */
  586. default:
  587. SystemCoreClock = HSI_VALUE;
  588. break;
  589. }
  590. /* Compute HCLK frequency --------------------------------------------------*/
  591. /* Get HCLK prescaler */
  592. tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
  593. /* HCLK frequency */
  594. SystemCoreClock >>= tmp;
  595. }
  596. /**
  597. * @brief Configures the System clock source, PLL Multiplier and Divider factors,
  598. * AHB/APBx prescalers and Flash settings
  599. * @Note This function should be called only once the RCC clock configuration
  600. * is reset to the default reset state (done in SystemInit() function).
  601. * @param None
  602. * @retval None
  603. */
  604. static void SetSysClock(void)
  605. {
  606. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx)|| defined(STM32F469_479xx)
  607. /******************************************************************************/
  608. /* PLL (clocked by HSE) used as System clock source */
  609. /******************************************************************************/
  610. __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
  611. /* Enable HSE */
  612. RCC->CR |= ((uint32_t)RCC_CR_HSEON);
  613. /* Wait till HSE is ready and if Time out is reached exit */
  614. do
  615. {
  616. HSEStatus = RCC->CR & RCC_CR_HSERDY;
  617. StartUpCounter++;
  618. } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
  619. if ((RCC->CR & RCC_CR_HSERDY) != RESET)
  620. {
  621. HSEStatus = (uint32_t)0x01;
  622. }
  623. else
  624. {
  625. HSEStatus = (uint32_t)0x00;
  626. }
  627. if (HSEStatus == (uint32_t)0x01)
  628. {
  629. /* Select regulator voltage output Scale 1 mode */
  630. RCC->APB1ENR |= RCC_APB1ENR_PWREN;
  631. PWR->CR |= PWR_CR_VOS;
  632. /* HCLK = SYSCLK / 1*/
  633. RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
  634. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F412xG) || defined(STM32F446xx) || defined(STM32F469_479xx)
  635. /* PCLK2 = HCLK / 2*/
  636. RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
  637. /* PCLK1 = HCLK / 4*/
  638. RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
  639. #endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F412xG || STM32F446xx || STM32F469_479xx */
  640. #if defined(STM32F401xx) || defined(STM32F413_423xx)
  641. /* PCLK2 = HCLK / 1*/
  642. RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
  643. /* PCLK1 = HCLK / 2*/
  644. RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
  645. #endif /* STM32F401xx || STM32F413_423xx */
  646. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F469_479xx)
  647. /* Configure the main PLL */
  648. RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
  649. (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
  650. #endif /* STM32F40_41xxx || STM32F401xx || STM32F427_437x || STM32F429_439xx || STM32F469_479xx */
  651. #if defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx)
  652. /* Configure the main PLL */
  653. RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
  654. (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24) | (PLL_R << 28);
  655. #endif /* STM32F412xG || STM32F413_423xx || STM32F446xx */
  656. /* Enable the main PLL */
  657. RCC->CR |= RCC_CR_PLLON;
  658. /* Wait till the main PLL is ready */
  659. while((RCC->CR & RCC_CR_PLLRDY) == 0)
  660. {
  661. }
  662. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  663. /* Enable the Over-drive to extend the clock frequency to 180 Mhz */
  664. PWR->CR |= PWR_CR_ODEN;
  665. while((PWR->CSR & PWR_CSR_ODRDY) == 0)
  666. {
  667. }
  668. PWR->CR |= PWR_CR_ODSWEN;
  669. while((PWR->CSR & PWR_CSR_ODSWRDY) == 0)
  670. {
  671. }
  672. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  673. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
  674. #endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  675. #if defined(STM32F40_41xxx) || defined(STM32F412xG)
  676. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  677. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
  678. #endif /* STM32F40_41xxx || STM32F412xG */
  679. #if defined(STM32F413_423xx)
  680. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  681. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_3WS;
  682. #endif /* STM32F413_423xx */
  683. #if defined(STM32F401xx)
  684. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  685. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_2WS;
  686. #endif /* STM32F401xx */
  687. /* Select the main PLL as system clock source */
  688. RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
  689. RCC->CFGR |= RCC_CFGR_SW_PLL;
  690. /* Wait till the main PLL is used as system clock source */
  691. while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
  692. {
  693. }
  694. }
  695. else
  696. { /* If HSE fails to start-up, the application will have wrong clock
  697. configuration. User can add here some code to deal with this error */
  698. }
  699. #elif defined(STM32F410xx) || defined(STM32F411xE)
  700. #if defined(USE_HSE_BYPASS)
  701. /******************************************************************************/
  702. /* PLL (clocked by HSE) used as System clock source */
  703. /******************************************************************************/
  704. __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
  705. /* Enable HSE and HSE BYPASS */
  706. RCC->CR |= ((uint32_t)RCC_CR_HSEON | RCC_CR_HSEBYP);
  707. /* Wait till HSE is ready and if Time out is reached exit */
  708. do
  709. {
  710. HSEStatus = RCC->CR & RCC_CR_HSERDY;
  711. StartUpCounter++;
  712. } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
  713. if ((RCC->CR & RCC_CR_HSERDY) != RESET)
  714. {
  715. HSEStatus = (uint32_t)0x01;
  716. }
  717. else
  718. {
  719. HSEStatus = (uint32_t)0x00;
  720. }
  721. if (HSEStatus == (uint32_t)0x01)
  722. {
  723. /* Select regulator voltage output Scale 1 mode */
  724. RCC->APB1ENR |= RCC_APB1ENR_PWREN;
  725. PWR->CR |= PWR_CR_VOS;
  726. /* HCLK = SYSCLK / 1*/
  727. RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
  728. /* PCLK2 = HCLK / 2*/
  729. RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
  730. /* PCLK1 = HCLK / 4*/
  731. RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
  732. /* Configure the main PLL */
  733. RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) |
  734. (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
  735. /* Enable the main PLL */
  736. RCC->CR |= RCC_CR_PLLON;
  737. /* Wait till the main PLL is ready */
  738. while((RCC->CR & RCC_CR_PLLRDY) == 0)
  739. {
  740. }
  741. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  742. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_2WS;
  743. /* Select the main PLL as system clock source */
  744. RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
  745. RCC->CFGR |= RCC_CFGR_SW_PLL;
  746. /* Wait till the main PLL is used as system clock source */
  747. while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
  748. {
  749. }
  750. }
  751. else
  752. { /* If HSE fails to start-up, the application will have wrong clock
  753. configuration. User can add here some code to deal with this error */
  754. }
  755. #else /* HSI will be used as PLL clock source */
  756. /* Select regulator voltage output Scale 1 mode */
  757. RCC->APB1ENR |= RCC_APB1ENR_PWREN;
  758. PWR->CR |= PWR_CR_VOS;
  759. /* HCLK = SYSCLK / 1*/
  760. RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
  761. /* PCLK2 = HCLK / 2*/
  762. RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
  763. /* PCLK1 = HCLK / 4*/
  764. RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
  765. /* Configure the main PLL */
  766. RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) -1) << 16) | (PLL_Q << 24);
  767. /* Enable the main PLL */
  768. RCC->CR |= RCC_CR_PLLON;
  769. /* Wait till the main PLL is ready */
  770. while((RCC->CR & RCC_CR_PLLRDY) == 0)
  771. {
  772. }
  773. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  774. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_2WS;
  775. /* Select the main PLL as system clock source */
  776. RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
  777. RCC->CFGR |= RCC_CFGR_SW_PLL;
  778. /* Wait till the main PLL is used as system clock source */
  779. while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
  780. {
  781. }
  782. #endif /* USE_HSE_BYPASS */
  783. #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F469_479xx */
  784. }
  785. #if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM)
  786. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
  787. defined(STM32F469xx) || defined(STM32F479xx)
  788. /**
  789. * @brief Setup the external memory controller.
  790. * Called in startup_stm32f4xx.s before jump to main.
  791. * This function configures the external memories (SRAM/SDRAM)
  792. * This SRAM/SDRAM will be used as program data memory (including heap and stack).
  793. * @param None
  794. * @retval None
  795. */
  796. void SystemInit_ExtMemCtl(void)
  797. {
  798. __IO uint32_t tmp = 0x00;
  799. register uint32_t tmpreg = 0, timeout = 0xFFFF;
  800. register uint32_t index;
  801. /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */
  802. RCC->AHB1ENR |= 0x000001F8;
  803. /* Delay after an RCC peripheral clock enabling */
  804. tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
  805. /* Connect PDx pins to FMC Alternate function */
  806. GPIOD->AFR[0] = 0x00CCC0CC;
  807. GPIOD->AFR[1] = 0xCCCCCCCC;
  808. /* Configure PDx pins in Alternate function mode */
  809. GPIOD->MODER = 0xAAAA0A8A;
  810. /* Configure PDx pins speed to 100 MHz */
  811. GPIOD->OSPEEDR = 0xFFFF0FCF;
  812. /* Configure PDx pins Output type to push-pull */
  813. GPIOD->OTYPER = 0x00000000;
  814. /* No pull-up, pull-down for PDx pins */
  815. GPIOD->PUPDR = 0x00000000;
  816. /* Connect PEx pins to FMC Alternate function */
  817. GPIOE->AFR[0] = 0xC00CC0CC;
  818. GPIOE->AFR[1] = 0xCCCCCCCC;
  819. /* Configure PEx pins in Alternate function mode */
  820. GPIOE->MODER = 0xAAAA828A;
  821. /* Configure PEx pins speed to 100 MHz */
  822. GPIOE->OSPEEDR = 0xFFFFC3CF;
  823. /* Configure PEx pins Output type to push-pull */
  824. GPIOE->OTYPER = 0x00000000;
  825. /* No pull-up, pull-down for PEx pins */
  826. GPIOE->PUPDR = 0x00000000;
  827. /* Connect PFx pins to FMC Alternate function */
  828. GPIOF->AFR[0] = 0xCCCCCCCC;
  829. GPIOF->AFR[1] = 0xCCCCCCCC;
  830. /* Configure PFx pins in Alternate function mode */
  831. GPIOF->MODER = 0xAA800AAA;
  832. /* Configure PFx pins speed to 50 MHz */
  833. GPIOF->OSPEEDR = 0xAA800AAA;
  834. /* Configure PFx pins Output type to push-pull */
  835. GPIOF->OTYPER = 0x00000000;
  836. /* No pull-up, pull-down for PFx pins */
  837. GPIOF->PUPDR = 0x00000000;
  838. /* Connect PGx pins to FMC Alternate function */
  839. GPIOG->AFR[0] = 0xCCCCCCCC;
  840. GPIOG->AFR[1] = 0xCCCCCCCC;
  841. /* Configure PGx pins in Alternate function mode */
  842. GPIOG->MODER = 0xAAAAAAAA;
  843. /* Configure PGx pins speed to 50 MHz */
  844. GPIOG->OSPEEDR = 0xAAAAAAAA;
  845. /* Configure PGx pins Output type to push-pull */
  846. GPIOG->OTYPER = 0x00000000;
  847. /* No pull-up, pull-down for PGx pins */
  848. GPIOG->PUPDR = 0x00000000;
  849. /* Connect PHx pins to FMC Alternate function */
  850. GPIOH->AFR[0] = 0x00C0CC00;
  851. GPIOH->AFR[1] = 0xCCCCCCCC;
  852. /* Configure PHx pins in Alternate function mode */
  853. GPIOH->MODER = 0xAAAA08A0;
  854. /* Configure PHx pins speed to 50 MHz */
  855. GPIOH->OSPEEDR = 0xAAAA08A0;
  856. /* Configure PHx pins Output type to push-pull */
  857. GPIOH->OTYPER = 0x00000000;
  858. /* No pull-up, pull-down for PHx pins */
  859. GPIOH->PUPDR = 0x00000000;
  860. /* Connect PIx pins to FMC Alternate function */
  861. GPIOI->AFR[0] = 0xCCCCCCCC;
  862. GPIOI->AFR[1] = 0x00000CC0;
  863. /* Configure PIx pins in Alternate function mode */
  864. GPIOI->MODER = 0x0028AAAA;
  865. /* Configure PIx pins speed to 50 MHz */
  866. GPIOI->OSPEEDR = 0x0028AAAA;
  867. /* Configure PIx pins Output type to push-pull */
  868. GPIOI->OTYPER = 0x00000000;
  869. /* No pull-up, pull-down for PIx pins */
  870. GPIOI->PUPDR = 0x00000000;
  871. /*-- FMC Configuration -------------------------------------------------------*/
  872. /* Enable the FMC interface clock */
  873. RCC->AHB3ENR |= 0x00000001;
  874. /* Delay after an RCC peripheral clock enabling */
  875. tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
  876. FMC_Bank5_6->SDCR[0] = 0x000019E4;
  877. FMC_Bank5_6->SDTR[0] = 0x01115351;
  878. /* SDRAM initialization sequence */
  879. /* Clock enable command */
  880. FMC_Bank5_6->SDCMR = 0x00000011;
  881. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  882. while((tmpreg != 0) && (timeout-- > 0))
  883. {
  884. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  885. }
  886. /* Delay */
  887. for (index = 0; index<1000; index++);
  888. /* PALL command */
  889. FMC_Bank5_6->SDCMR = 0x00000012;
  890. timeout = 0xFFFF;
  891. while((tmpreg != 0) && (timeout-- > 0))
  892. {
  893. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  894. }
  895. /* Auto refresh command */
  896. FMC_Bank5_6->SDCMR = 0x00000073;
  897. timeout = 0xFFFF;
  898. while((tmpreg != 0) && (timeout-- > 0))
  899. {
  900. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  901. }
  902. /* MRD register program */
  903. FMC_Bank5_6->SDCMR = 0x00046014;
  904. timeout = 0xFFFF;
  905. while((tmpreg != 0) && (timeout-- > 0))
  906. {
  907. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  908. }
  909. /* Set refresh count */
  910. tmpreg = FMC_Bank5_6->SDRTR;
  911. FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
  912. /* Disable write protection */
  913. tmpreg = FMC_Bank5_6->SDCR[0];
  914. FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
  915. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  916. /* Configure and enable Bank1_SRAM2 */
  917. FMC_Bank1->BTCR[2] = 0x00001011;
  918. FMC_Bank1->BTCR[3] = 0x00000201;
  919. FMC_Bank1E->BWTR[2] = 0x0fffffff;
  920. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  921. #if defined(STM32F469xx) || defined(STM32F479xx)
  922. /* Configure and enable Bank1_SRAM2 */
  923. FMC_Bank1->BTCR[2] = 0x00001091;
  924. FMC_Bank1->BTCR[3] = 0x00110212;
  925. FMC_Bank1E->BWTR[2] = 0x0fffffff;
  926. #endif /* STM32F469xx || STM32F479xx */
  927. (void)(tmp);
  928. }
  929. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  930. #elif defined (DATA_IN_ExtSRAM)
  931. /**
  932. * @brief Setup the external memory controller. Called in startup_stm32f4xx.s
  933. * before jump to __main
  934. * @param None
  935. * @retval None
  936. */
  937. /**
  938. * @brief Setup the external memory controller.
  939. * Called in startup_stm32f4xx.s before jump to main.
  940. * This function configures the external SRAM mounted on STM324xG_EVAL/STM324x7I boards
  941. * This SRAM will be used as program data memory (including heap and stack).
  942. * @param None
  943. * @retval None
  944. */
  945. void SystemInit_ExtMemCtl(void)
  946. {
  947. /*-- GPIOs Configuration -----------------------------------------------------*/
  948. /*
  949. +-------------------+--------------------+------------------+--------------+
  950. + SRAM pins assignment +
  951. +-------------------+--------------------+------------------+--------------+
  952. | PD0 <-> FMC_D2 | PE0 <-> FMC_NBL0 | PF0 <-> FMC_A0 | PG0 <-> FMC_A10 |
  953. | PD1 <-> FMC_D3 | PE1 <-> FMC_NBL1 | PF1 <-> FMC_A1 | PG1 <-> FMC_A11 |
  954. | PD4 <-> FMC_NOE | PE3 <-> FMC_A19 | PF2 <-> FMC_A2 | PG2 <-> FMC_A12 |
  955. | PD5 <-> FMC_NWE | PE4 <-> FMC_A20 | PF3 <-> FMC_A3 | PG3 <-> FMC_A13 |
  956. | PD8 <-> FMC_D13 | PE7 <-> FMC_D4 | PF4 <-> FMC_A4 | PG4 <-> FMC_A14 |
  957. | PD9 <-> FMC_D14 | PE8 <-> FMC_D5 | PF5 <-> FMC_A5 | PG5 <-> FMC_A15 |
  958. | PD10 <-> FMC_D15 | PE9 <-> FMC_D6 | PF12 <-> FMC_A6 | PG9 <-> FMC_NE2 |
  959. | PD11 <-> FMC_A16 | PE10 <-> FMC_D7 | PF13 <-> FMC_A7 |-----------------+
  960. | PD12 <-> FMC_A17 | PE11 <-> FMC_D8 | PF14 <-> FMC_A8 |
  961. | PD13 <-> FMC_A18 | PE12 <-> FMC_D9 | PF15 <-> FMC_A9 |
  962. | PD14 <-> FMC_D0 | PE13 <-> FMC_D10 |-----------------+
  963. | PD15 <-> FMC_D1 | PE14 <-> FMC_D11 |
  964. | | PE15 <-> FMC_D12 |
  965. +------------------+------------------+
  966. */
  967. /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
  968. RCC->AHB1ENR |= 0x00000078;
  969. /* Connect PDx pins to FMC Alternate function */
  970. GPIOD->AFR[0] = 0x00cc00cc;
  971. GPIOD->AFR[1] = 0xcccccccc;
  972. /* Configure PDx pins in Alternate function mode */
  973. GPIOD->MODER = 0xaaaa0a0a;
  974. /* Configure PDx pins speed to 100 MHz */
  975. GPIOD->OSPEEDR = 0xffff0f0f;
  976. /* Configure PDx pins Output type to push-pull */
  977. GPIOD->OTYPER = 0x00000000;
  978. /* No pull-up, pull-down for PDx pins */
  979. GPIOD->PUPDR = 0x00000000;
  980. /* Connect PEx pins to FMC Alternate function */
  981. GPIOE->AFR[0] = 0xcccccccc;
  982. GPIOE->AFR[1] = 0xcccccccc;
  983. /* Configure PEx pins in Alternate function mode */
  984. GPIOE->MODER = 0xaaaaaaaa;
  985. /* Configure PEx pins speed to 100 MHz */
  986. GPIOE->OSPEEDR = 0xffffffff;
  987. /* Configure PEx pins Output type to push-pull */
  988. GPIOE->OTYPER = 0x00000000;
  989. /* No pull-up, pull-down for PEx pins */
  990. GPIOE->PUPDR = 0x00000000;
  991. /* Connect PFx pins to FMC Alternate function */
  992. GPIOF->AFR[0] = 0x00cccccc;
  993. GPIOF->AFR[1] = 0xcccc0000;
  994. /* Configure PFx pins in Alternate function mode */
  995. GPIOF->MODER = 0xaa000aaa;
  996. /* Configure PFx pins speed to 100 MHz */
  997. GPIOF->OSPEEDR = 0xff000fff;
  998. /* Configure PFx pins Output type to push-pull */
  999. GPIOF->OTYPER = 0x00000000;
  1000. /* No pull-up, pull-down for PFx pins */
  1001. GPIOF->PUPDR = 0x00000000;
  1002. /* Connect PGx pins to FMC Alternate function */
  1003. GPIOG->AFR[0] = 0x00cccccc;
  1004. GPIOG->AFR[1] = 0x000000c0;
  1005. /* Configure PGx pins in Alternate function mode */
  1006. GPIOG->MODER = 0x00080aaa;
  1007. /* Configure PGx pins speed to 100 MHz */
  1008. GPIOG->OSPEEDR = 0x000c0fff;
  1009. /* Configure PGx pins Output type to push-pull */
  1010. GPIOG->OTYPER = 0x00000000;
  1011. /* No pull-up, pull-down for PGx pins */
  1012. GPIOG->PUPDR = 0x00000000;
  1013. /*-- FMC Configuration ------------------------------------------------------*/
  1014. /* Enable the FMC/FSMC interface clock */
  1015. RCC->AHB3ENR |= 0x00000001;
  1016. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  1017. /* Configure and enable Bank1_SRAM2 */
  1018. FMC_Bank1->BTCR[2] = 0x00001011;
  1019. FMC_Bank1->BTCR[3] = 0x00000201;
  1020. FMC_Bank1E->BWTR[2] = 0x0fffffff;
  1021. #endif /* STM32F427_437xx || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  1022. #if defined(STM32F40_41xxx)
  1023. /* Configure and enable Bank1_SRAM2 */
  1024. FSMC_Bank1->BTCR[2] = 0x00001011;
  1025. FSMC_Bank1->BTCR[3] = 0x00000201;
  1026. FSMC_Bank1E->BWTR[2] = 0x0fffffff;
  1027. #endif /* STM32F40_41xxx */
  1028. /*
  1029. Bank1_SRAM2 is configured as follow:
  1030. In case of FSMC configuration
  1031. NORSRAMTimingStructure.FSMC_AddressSetupTime = 1;
  1032. NORSRAMTimingStructure.FSMC_AddressHoldTime = 0;
  1033. NORSRAMTimingStructure.FSMC_DataSetupTime = 2;
  1034. NORSRAMTimingStructure.FSMC_BusTurnAroundDuration = 0;
  1035. NORSRAMTimingStructure.FSMC_CLKDivision = 0;
  1036. NORSRAMTimingStructure.FSMC_DataLatency = 0;
  1037. NORSRAMTimingStructure.FSMC_AccessMode = FMC_AccessMode_A;
  1038. FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
  1039. FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
  1040. FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
  1041. FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
  1042. FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
  1043. FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
  1044. FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
  1045. FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
  1046. FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
  1047. FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
  1048. FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
  1049. FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
  1050. FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
  1051. FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &NORSRAMTimingStructure;
  1052. FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &NORSRAMTimingStructure;
  1053. In case of FMC configuration
  1054. NORSRAMTimingStructure.FMC_AddressSetupTime = 1;
  1055. NORSRAMTimingStructure.FMC_AddressHoldTime = 0;
  1056. NORSRAMTimingStructure.FMC_DataSetupTime = 2;
  1057. NORSRAMTimingStructure.FMC_BusTurnAroundDuration = 0;
  1058. NORSRAMTimingStructure.FMC_CLKDivision = 0;
  1059. NORSRAMTimingStructure.FMC_DataLatency = 0;
  1060. NORSRAMTimingStructure.FMC_AccessMode = FMC_AccessMode_A;
  1061. FMC_NORSRAMInitStructure.FMC_Bank = FMC_Bank1_NORSRAM2;
  1062. FMC_NORSRAMInitStructure.FMC_DataAddressMux = FMC_DataAddressMux_Disable;
  1063. FMC_NORSRAMInitStructure.FMC_MemoryType = FMC_MemoryType_SRAM;
  1064. FMC_NORSRAMInitStructure.FMC_MemoryDataWidth = FMC_MemoryDataWidth_16b;
  1065. FMC_NORSRAMInitStructure.FMC_BurstAccessMode = FMC_BurstAccessMode_Disable;
  1066. FMC_NORSRAMInitStructure.FMC_AsynchronousWait = FMC_AsynchronousWait_Disable;
  1067. FMC_NORSRAMInitStructure.FMC_WaitSignalPolarity = FMC_WaitSignalPolarity_Low;
  1068. FMC_NORSRAMInitStructure.FMC_WrapMode = FMC_WrapMode_Disable;
  1069. FMC_NORSRAMInitStructure.FMC_WaitSignalActive = FMC_WaitSignalActive_BeforeWaitState;
  1070. FMC_NORSRAMInitStructure.FMC_WriteOperation = FMC_WriteOperation_Enable;
  1071. FMC_NORSRAMInitStructure.FMC_WaitSignal = FMC_WaitSignal_Disable;
  1072. FMC_NORSRAMInitStructure.FMC_ExtendedMode = FMC_ExtendedMode_Disable;
  1073. FMC_NORSRAMInitStructure.FMC_WriteBurst = FMC_WriteBurst_Disable;
  1074. FMC_NORSRAMInitStructure.FMC_ContinousClock = FMC_CClock_SyncOnly;
  1075. FMC_NORSRAMInitStructure.FMC_ReadWriteTimingStruct = &NORSRAMTimingStructure;
  1076. FMC_NORSRAMInitStructure.FMC_WriteTimingStruct = &NORSRAMTimingStructure;
  1077. */
  1078. }
  1079. #elif defined (DATA_IN_ExtSDRAM)
  1080. /**
  1081. * @brief Setup the external memory controller.
  1082. * Called in startup_stm32f4xx.s before jump to main.
  1083. * This function configures the external SDRAM mounted on STM324x9I_EVAL board
  1084. * This SDRAM will be used as program data memory (including heap and stack).
  1085. * @param None
  1086. * @retval None
  1087. */
  1088. void SystemInit_ExtMemCtl(void)
  1089. {
  1090. register uint32_t tmpreg = 0, timeout = 0xFFFF;
  1091. register uint32_t index;
  1092. /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
  1093. clock */
  1094. RCC->AHB1ENR |= 0x000001FC;
  1095. /* Connect PCx pins to FMC Alternate function */
  1096. GPIOC->AFR[0] = 0x0000000c;
  1097. GPIOC->AFR[1] = 0x00007700;
  1098. /* Configure PCx pins in Alternate function mode */
  1099. GPIOC->MODER = 0x00a00002;
  1100. /* Configure PCx pins speed to 50 MHz */
  1101. GPIOC->OSPEEDR = 0x00a00002;
  1102. /* Configure PCx pins Output type to push-pull */
  1103. GPIOC->OTYPER = 0x00000000;
  1104. /* No pull-up, pull-down for PCx pins */
  1105. GPIOC->PUPDR = 0x00500000;
  1106. /* Connect PDx pins to FMC Alternate function */
  1107. GPIOD->AFR[0] = 0x000000CC;
  1108. GPIOD->AFR[1] = 0xCC000CCC;
  1109. /* Configure PDx pins in Alternate function mode */
  1110. GPIOD->MODER = 0xA02A000A;
  1111. /* Configure PDx pins speed to 50 MHz */
  1112. GPIOD->OSPEEDR = 0xA02A000A;
  1113. /* Configure PDx pins Output type to push-pull */
  1114. GPIOD->OTYPER = 0x00000000;
  1115. /* No pull-up, pull-down for PDx pins */
  1116. GPIOD->PUPDR = 0x00000000;
  1117. /* Connect PEx pins to FMC Alternate function */
  1118. GPIOE->AFR[0] = 0xC00000CC;
  1119. GPIOE->AFR[1] = 0xCCCCCCCC;
  1120. /* Configure PEx pins in Alternate function mode */
  1121. GPIOE->MODER = 0xAAAA800A;
  1122. /* Configure PEx pins speed to 50 MHz */
  1123. GPIOE->OSPEEDR = 0xAAAA800A;
  1124. /* Configure PEx pins Output type to push-pull */
  1125. GPIOE->OTYPER = 0x00000000;
  1126. /* No pull-up, pull-down for PEx pins */
  1127. GPIOE->PUPDR = 0x00000000;
  1128. /* Connect PFx pins to FMC Alternate function */
  1129. GPIOF->AFR[0] = 0xcccccccc;
  1130. GPIOF->AFR[1] = 0xcccccccc;
  1131. /* Configure PFx pins in Alternate function mode */
  1132. GPIOF->MODER = 0xAA800AAA;
  1133. /* Configure PFx pins speed to 50 MHz */
  1134. GPIOF->OSPEEDR = 0xAA800AAA;
  1135. /* Configure PFx pins Output type to push-pull */
  1136. GPIOF->OTYPER = 0x00000000;
  1137. /* No pull-up, pull-down for PFx pins */
  1138. GPIOF->PUPDR = 0x00000000;
  1139. /* Connect PGx pins to FMC Alternate function */
  1140. GPIOG->AFR[0] = 0xcccccccc;
  1141. GPIOG->AFR[1] = 0xcccccccc;
  1142. /* Configure PGx pins in Alternate function mode */
  1143. GPIOG->MODER = 0xaaaaaaaa;
  1144. /* Configure PGx pins speed to 50 MHz */
  1145. GPIOG->OSPEEDR = 0xaaaaaaaa;
  1146. /* Configure PGx pins Output type to push-pull */
  1147. GPIOG->OTYPER = 0x00000000;
  1148. /* No pull-up, pull-down for PGx pins */
  1149. GPIOG->PUPDR = 0x00000000;
  1150. /* Connect PHx pins to FMC Alternate function */
  1151. GPIOH->AFR[0] = 0x00C0CC00;
  1152. GPIOH->AFR[1] = 0xCCCCCCCC;
  1153. /* Configure PHx pins in Alternate function mode */
  1154. GPIOH->MODER = 0xAAAA08A0;
  1155. /* Configure PHx pins speed to 50 MHz */
  1156. GPIOH->OSPEEDR = 0xAAAA08A0;
  1157. /* Configure PHx pins Output type to push-pull */
  1158. GPIOH->OTYPER = 0x00000000;
  1159. /* No pull-up, pull-down for PHx pins */
  1160. GPIOH->PUPDR = 0x00000000;
  1161. /* Connect PIx pins to FMC Alternate function */
  1162. GPIOI->AFR[0] = 0xCCCCCCCC;
  1163. GPIOI->AFR[1] = 0x00000CC0;
  1164. /* Configure PIx pins in Alternate function mode */
  1165. GPIOI->MODER = 0x0028AAAA;
  1166. /* Configure PIx pins speed to 50 MHz */
  1167. GPIOI->OSPEEDR = 0x0028AAAA;
  1168. /* Configure PIx pins Output type to push-pull */
  1169. GPIOI->OTYPER = 0x00000000;
  1170. /* No pull-up, pull-down for PIx pins */
  1171. GPIOI->PUPDR = 0x00000000;
  1172. /*-- FMC Configuration ------------------------------------------------------*/
  1173. /* Enable the FMC interface clock */
  1174. RCC->AHB3ENR |= 0x00000001;
  1175. /* Configure and enable SDRAM bank1 */
  1176. FMC_Bank5_6->SDCR[0] = 0x000039D0;
  1177. FMC_Bank5_6->SDTR[0] = 0x01115351;
  1178. /* SDRAM initialization sequence */
  1179. /* Clock enable command */
  1180. FMC_Bank5_6->SDCMR = 0x00000011;
  1181. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1182. while((tmpreg != 0) & (timeout-- > 0))
  1183. {
  1184. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1185. }
  1186. /* Delay */
  1187. for (index = 0; index<1000; index++);
  1188. /* PALL command */
  1189. FMC_Bank5_6->SDCMR = 0x00000012;
  1190. timeout = 0xFFFF;
  1191. while((tmpreg != 0) & (timeout-- > 0))
  1192. {
  1193. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1194. }
  1195. /* Auto refresh command */
  1196. FMC_Bank5_6->SDCMR = 0x00000073;
  1197. timeout = 0xFFFF;
  1198. while((tmpreg != 0) & (timeout-- > 0))
  1199. {
  1200. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1201. }
  1202. /* MRD register program */
  1203. FMC_Bank5_6->SDCMR = 0x00046014;
  1204. timeout = 0xFFFF;
  1205. while((tmpreg != 0) & (timeout-- > 0))
  1206. {
  1207. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1208. }
  1209. /* Set refresh count */
  1210. tmpreg = FMC_Bank5_6->SDRTR;
  1211. FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
  1212. /* Disable write protection */
  1213. tmpreg = FMC_Bank5_6->SDCR[0];
  1214. FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
  1215. /*
  1216. Bank1_SDRAM is configured as follow:
  1217. FMC_SDRAMTimingInitStructure.FMC_LoadToActiveDelay = 2;
  1218. FMC_SDRAMTimingInitStructure.FMC_ExitSelfRefreshDelay = 6;
  1219. FMC_SDRAMTimingInitStructure.FMC_SelfRefreshTime = 4;
  1220. FMC_SDRAMTimingInitStructure.FMC_RowCycleDelay = 6;
  1221. FMC_SDRAMTimingInitStructure.FMC_WriteRecoveryTime = 2;
  1222. FMC_SDRAMTimingInitStructure.FMC_RPDelay = 2;
  1223. FMC_SDRAMTimingInitStructure.FMC_RCDDelay = 2;
  1224. FMC_SDRAMInitStructure.FMC_Bank = SDRAM_BANK;
  1225. FMC_SDRAMInitStructure.FMC_ColumnBitsNumber = FMC_ColumnBits_Number_8b;
  1226. FMC_SDRAMInitStructure.FMC_RowBitsNumber = FMC_RowBits_Number_11b;
  1227. FMC_SDRAMInitStructure.FMC_SDMemoryDataWidth = FMC_SDMemory_Width_16b;
  1228. FMC_SDRAMInitStructure.FMC_InternalBankNumber = FMC_InternalBank_Number_4;
  1229. FMC_SDRAMInitStructure.FMC_CASLatency = FMC_CAS_Latency_3;
  1230. FMC_SDRAMInitStructure.FMC_WriteProtection = FMC_Write_Protection_Disable;
  1231. FMC_SDRAMInitStructure.FMC_SDClockPeriod = FMC_SDClock_Period_2;
  1232. FMC_SDRAMInitStructure.FMC_ReadBurst = FMC_Read_Burst_disable;
  1233. FMC_SDRAMInitStructure.FMC_ReadPipeDelay = FMC_ReadPipe_Delay_1;
  1234. FMC_SDRAMInitStructure.FMC_SDRAMTimingStruct = &FMC_SDRAMTimingInitStructure;
  1235. */
  1236. }
  1237. #endif /* DATA_IN_ExtSDRAM && DATA_IN_ExtSRAM */
  1238. /**
  1239. * @}
  1240. */
  1241. /**
  1242. * @}
  1243. */
  1244. /**
  1245. * @}
  1246. */
  1247. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/