system_stm32f4xx.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  1. /**
  2. ******************************************************************************
  3. * @file system_stm32f4xx.c
  4. * @author MCD Application Team
  5. * @version V1.8.1
  6. * @date 27-January-2022
  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. * Copyright (c) 2016 STMicroelectronics.
  289. * All rights reserved.
  290. *
  291. * This software is licensed under terms that can be found in the LICENSE file
  292. * in the root directory of this software component.
  293. * If no LICENSE file comes with this software, it is provided AS-IS.
  294. *
  295. ******************************************************************************
  296. */
  297. /** @addtogroup CMSIS
  298. * @{
  299. */
  300. /** @addtogroup stm32f4xx_system
  301. * @{
  302. */
  303. /** @addtogroup STM32F4xx_System_Private_Includes
  304. * @{
  305. */
  306. #include "stm32f4xx.h"
  307. /**
  308. * @}
  309. */
  310. /** @addtogroup STM32F4xx_System_Private_TypesDefinitions
  311. * @{
  312. */
  313. /**
  314. * @}
  315. */
  316. /** @addtogroup STM32F4xx_System_Private_Defines
  317. * @{
  318. */
  319. /************************* Miscellaneous Configuration ************************/
  320. /*!< Uncomment the following line if you need to use external SRAM or SDRAM mounted
  321. on STM324xG_EVAL/STM324x7I_EVAL/STM324x9I_EVAL boards as data memory */
  322. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx) || defined(STM32F413_423xx)
  323. /* #define DATA_IN_ExtSRAM */
  324. #endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F469_479xx || STM32F413_423xx */
  325. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  326. /* #define DATA_IN_ExtSDRAM */
  327. #endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  328. #if defined(STM32F410xx) || defined(STM32F411xE)
  329. /*!< Uncomment the following line if you need to clock the STM32F410xx/STM32F411xE by HSE Bypass
  330. through STLINK MCO pin of STM32F103 microcontroller. The frequency cannot be changed
  331. and is fixed at 8 MHz.
  332. Hardware configuration needed for Nucleo Board:
  333. – SB54, SB55 OFF
  334. – R35 removed
  335. – SB16, SB50 ON */
  336. /* #define USE_HSE_BYPASS */
  337. #if defined(USE_HSE_BYPASS)
  338. #define HSE_BYPASS_INPUT_FREQUENCY 8000000
  339. #endif /* USE_HSE_BYPASS */
  340. #endif /* STM32F410xx || STM32F411xE */
  341. /*!< Uncomment the following line if you need to relocate your vector Table in
  342. Internal SRAM. */
  343. /* #define VECT_TAB_SRAM */
  344. #define VECT_TAB_OFFSET 0x80000 /*!< Vector Table base offset field. \
  345. This value must be a multiple of 0x200. */
  346. /******************************************************************************/
  347. /************************* PLL Parameters *************************************/
  348. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F469_479xx)
  349. /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
  350. #define PLL_M 8
  351. #elif defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx)
  352. #define PLL_M 8
  353. #elif defined(STM32F410xx) || defined(STM32F411xE)
  354. #if defined(USE_HSE_BYPASS)
  355. #define PLL_M 8
  356. #else /* !USE_HSE_BYPASS */
  357. #define PLL_M 16
  358. #endif /* USE_HSE_BYPASS */
  359. #else
  360. #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F469_479xx */
  361. /* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */
  362. #define PLL_Q 4
  363. #if defined(STM32F446xx)
  364. /* PLL division factor for I2S, SAI, SYSTEM and SPDIF: Clock = PLL_VCO / PLLR */
  365. #define PLL_R 7
  366. #elif defined(STM32F412xG) || defined(STM32F413_423xx)
  367. #define PLL_R 2
  368. #else
  369. #endif /* STM32F446xx */
  370. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  371. #define PLL_N 160
  372. /* SYSCLK = PLL_VCO / PLL_P */
  373. #define PLL_P 2
  374. #endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  375. #if defined(STM32F40_41xxx)
  376. #define PLL_N 336
  377. /* SYSCLK = PLL_VCO / PLL_P */
  378. #define PLL_P 2
  379. #endif /* STM32F40_41xxx */
  380. #if defined(STM32F401xx)
  381. #define PLL_N 336
  382. /* SYSCLK = PLL_VCO / PLL_P */
  383. #define PLL_P 4
  384. #endif /* STM32F401xx */
  385. #if defined(STM32F410xx) || defined(STM32F411xE) || defined(STM32F412xG) || defined(STM32F413_423xx)
  386. #define PLL_N 400
  387. /* SYSCLK = PLL_VCO / PLL_P */
  388. #define PLL_P 4
  389. #endif /* STM32F410xx || STM32F411xE || STM32F412xG || STM32F413_423xx */
  390. /******************************************************************************/
  391. /**
  392. * @}
  393. */
  394. /** @addtogroup STM32F4xx_System_Private_Macros
  395. * @{
  396. */
  397. /**
  398. * @}
  399. */
  400. /** @addtogroup STM32F4xx_System_Private_Variables
  401. * @{
  402. */
  403. #if defined(STM32F40_41xxx)
  404. uint32_t SystemCoreClock = 168000000;
  405. #endif /* STM32F40_41xxx */
  406. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  407. uint32_t SystemCoreClock = 180000000;
  408. #endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  409. #if defined(STM32F401xx)
  410. uint32_t SystemCoreClock = 84000000;
  411. #endif /* STM32F401xx */
  412. #if defined(STM32F410xx) || defined(STM32F411xE) || defined(STM32F412xG) || defined(STM32F413_423xx)
  413. uint32_t SystemCoreClock = 100000000;
  414. #endif /* STM32F410xx || STM32F401xE || STM32F412xG || STM32F413_423xx */
  415. __I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
  416. /**
  417. * @}
  418. */
  419. /** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
  420. * @{
  421. */
  422. static void SetSysClock(void);
  423. #if defined(DATA_IN_ExtSRAM) || defined(DATA_IN_ExtSDRAM)
  424. static void SystemInit_ExtMemCtl(void);
  425. #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
  426. /**
  427. * @}
  428. */
  429. /** @addtogroup STM32F4xx_System_Private_Functions
  430. * @{
  431. */
  432. /**
  433. * @brief Setup the microcontroller system
  434. * Initialize the Embedded Flash Interface, the PLL and update the
  435. * SystemFrequency variable.
  436. * @param None
  437. * @retval None
  438. */
  439. void SystemInit(void)
  440. {
  441. /* FPU settings ------------------------------------------------------------*/
  442. #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
  443. SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */
  444. #endif
  445. /* Reset the RCC clock configuration to the default reset state ------------*/
  446. /* Set HSION bit */
  447. RCC->CR |= (uint32_t)0x00000001;
  448. /* Reset CFGR register */
  449. RCC->CFGR = 0x00000000;
  450. // // MCO1(12.288MHz)
  451. // RCC->CFGR |= 0x03 << 21; // add by zhoutao(2023-09-19)
  452. // RCC->CFGR |= 0x06 << 24; // add by zhoutao(2023-09-19)
  453. // MCO2(12.288MHz)
  454. RCC->CFGR |= 0x01 << 30; // add by zhoutao(2023-09-19)
  455. RCC->CFGR |= 0x07 << 27; // add by zhoutao(2023-09-19)
  456. /* Reset HSEON, CSSON and PLLON bits */
  457. RCC->CR &= (uint32_t)0xFEF6FFFF;
  458. /* Reset PLLCFGR register */
  459. RCC->PLLCFGR = 0x24003010;
  460. /* Reset HSEBYP bit */
  461. RCC->CR &= (uint32_t)0xFFFBFFFF;
  462. /* Disable all interrupts */
  463. RCC->CIR = 0x00000000;
  464. #if defined(DATA_IN_ExtSRAM) || defined(DATA_IN_ExtSDRAM)
  465. SystemInit_ExtMemCtl();
  466. #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
  467. /* Configure the System clock source, PLL Multiplier and Divider factors,
  468. AHB/APBx prescalers and Flash settings ----------------------------------*/
  469. SetSysClock();
  470. /* Configure the Vector Table location add offset address ------------------*/
  471. #ifdef VECT_TAB_SRAM
  472. SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
  473. #else
  474. SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
  475. #endif
  476. }
  477. /**
  478. * @brief Update SystemCoreClock variable according to Clock Register Values.
  479. * The SystemCoreClock variable contains the core clock (HCLK), it can
  480. * be used by the user application to setup the SysTick timer or configure
  481. * other parameters.
  482. *
  483. * @note Each time the core clock (HCLK) changes, this function must be called
  484. * to update SystemCoreClock variable value. Otherwise, any configuration
  485. * based on this variable will be incorrect.
  486. *
  487. * @note - The system frequency computed by this function is not the real
  488. * frequency in the chip. It is calculated based on the predefined
  489. * constant and the selected clock source:
  490. *
  491. * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
  492. *
  493. * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
  494. *
  495. * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
  496. * or HSI_VALUE(*) multiplied/divided by the PLL factors.
  497. *
  498. * (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value
  499. * 16 MHz) but the real value may vary depending on the variations
  500. * in voltage and temperature.
  501. *
  502. * (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value
  503. * 25 MHz), user has to ensure that HSE_VALUE is same as the real
  504. * frequency of the crystal used. Otherwise, this function may
  505. * have wrong result.
  506. *
  507. * - The result of this function could be not correct when using fractional
  508. * value for HSE crystal.
  509. *
  510. * @param None
  511. * @retval None
  512. */
  513. void SystemCoreClockUpdate(void)
  514. {
  515. uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
  516. #if defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx)
  517. uint32_t pllr = 2;
  518. #endif /* STM32F412xG || STM32F413_423xx || STM32F446xx */
  519. /* Get SYSCLK source -------------------------------------------------------*/
  520. tmp = RCC->CFGR & RCC_CFGR_SWS;
  521. switch (tmp)
  522. {
  523. case 0x00: /* HSI used as system clock source */
  524. SystemCoreClock = HSI_VALUE;
  525. break;
  526. case 0x04: /* HSE used as system clock source */
  527. SystemCoreClock = HSE_VALUE;
  528. break;
  529. case 0x08: /* PLL P used as system clock source */
  530. /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
  531. SYSCLK = PLL_VCO / PLL_P
  532. */
  533. pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
  534. pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
  535. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  536. if (pllsource != 0)
  537. {
  538. /* HSE used as PLL clock source */
  539. pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  540. }
  541. else
  542. {
  543. /* HSI used as PLL clock source */
  544. pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  545. }
  546. #elif defined(STM32F410xx) || defined(STM32F411xE)
  547. #if defined(USE_HSE_BYPASS)
  548. if (pllsource != 0)
  549. {
  550. /* HSE used as PLL clock source */
  551. pllvco = (HSE_BYPASS_INPUT_FREQUENCY / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  552. }
  553. #else
  554. if (pllsource == 0)
  555. {
  556. /* HSI used as PLL clock source */
  557. pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  558. }
  559. #endif /* USE_HSE_BYPASS */
  560. #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F412xG || STM32F413_423xx || STM32F446xx || STM32F469_479xx */
  561. pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >> 16) + 1) * 2;
  562. SystemCoreClock = pllvco / pllp;
  563. break;
  564. #if defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx)
  565. case 0x0C: /* PLL R used as system clock source */
  566. /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
  567. SYSCLK = PLL_VCO / PLL_R
  568. */
  569. pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
  570. pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
  571. if (pllsource != 0)
  572. {
  573. /* HSE used as PLL clock source */
  574. pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  575. }
  576. else
  577. {
  578. /* HSI used as PLL clock source */
  579. pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
  580. }
  581. pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 28) + 1) * 2;
  582. SystemCoreClock = pllvco / pllr;
  583. break;
  584. #endif /* STM32F412xG || STM32F413_423xx || STM32F446xx */
  585. default:
  586. SystemCoreClock = HSI_VALUE;
  587. break;
  588. }
  589. /* Compute HCLK frequency --------------------------------------------------*/
  590. /* Get HCLK prescaler */
  591. tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
  592. /* HCLK frequency */
  593. SystemCoreClock >>= tmp;
  594. }
  595. /**
  596. * @brief Configures the System clock source, PLL Multiplier and Divider factors,
  597. * AHB/APBx prescalers and Flash settings
  598. * @Note This function should be called only once the RCC clock configuration
  599. * is reset to the default reset state (done in SystemInit() function).
  600. * @param None
  601. * @retval None
  602. */
  603. static void SetSysClock(void)
  604. {
  605. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  606. /******************************************************************************/
  607. /* PLL (clocked by HSE) used as System clock source */
  608. /******************************************************************************/
  609. __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
  610. /* Enable HSE */
  611. RCC->CR |= ((uint32_t)RCC_CR_HSEON);
  612. /* Wait till HSE is ready and if Time out is reached exit */
  613. do
  614. {
  615. HSEStatus = RCC->CR & RCC_CR_HSERDY;
  616. StartUpCounter++;
  617. } while ((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
  618. if ((RCC->CR & RCC_CR_HSERDY) != RESET)
  619. {
  620. HSEStatus = (uint32_t)0x01;
  621. }
  622. else
  623. {
  624. HSEStatus = (uint32_t)0x00;
  625. }
  626. if (HSEStatus == (uint32_t)0x01)
  627. {
  628. /* Select regulator voltage output Scale 1 mode */
  629. RCC->APB1ENR |= RCC_APB1ENR_PWREN;
  630. PWR->CR |= PWR_CR_VOS_1; // PWR_CR_VOS;//ģʽ3
  631. /* HCLK = SYSCLK / 1*/
  632. RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
  633. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F412xG) || defined(STM32F446xx) || defined(STM32F469_479xx)
  634. /* PCLK2 = HCLK / 2*/
  635. RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
  636. /* PCLK1 = HCLK / 4*/
  637. RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
  638. #endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F412xG || STM32F446xx || STM32F469_479xx */
  639. #if defined(STM32F401xx) || defined(STM32F413_423xx)
  640. /* PCLK2 = HCLK / 1*/
  641. RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
  642. /* PCLK1 = HCLK / 2*/
  643. RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
  644. #endif /* STM32F401xx || STM32F413_423xx */
  645. #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F469_479xx)
  646. /* Configure the main PLL */
  647. RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) |
  648. (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
  649. #endif /* STM32F40_41xxx || STM32F401xx || STM32F427_437x || STM32F429_439xx || STM32F469_479xx */
  650. #if defined(STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx)
  651. /* Configure the main PLL */
  652. RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) |
  653. (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24) | (PLL_R << 28);
  654. #endif /* STM32F412xG || STM32F413_423xx || STM32F446xx */
  655. /* Enable the main PLL */
  656. RCC->CR |= RCC_CR_PLLON;
  657. /* Wait till the main PLL is ready */
  658. while ((RCC->CR & RCC_CR_PLLRDY) == 0)
  659. {
  660. }
  661. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  662. /* Enable the Over-drive to extend the clock frequency to 180 Mhz */
  663. PWR->CR |= PWR_CR_ODEN;
  664. while ((PWR->CSR & PWR_CSR_ODRDY) == 0)
  665. {
  666. }
  667. PWR->CR |= PWR_CR_ODSWEN;
  668. while ((PWR->CSR & PWR_CSR_ODSWRDY) == 0)
  669. {
  670. }
  671. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  672. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS;
  673. #endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  674. #if defined(STM32F40_41xxx) || defined(STM32F412xG)
  675. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  676. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS;
  677. #endif /* STM32F40_41xxx || STM32F412xG */
  678. #if defined(STM32F413_423xx)
  679. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  680. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_3WS;
  681. #endif /* STM32F413_423xx */
  682. #if defined(STM32F401xx)
  683. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  684. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_2WS;
  685. #endif /* STM32F401xx */
  686. /* Select the main PLL as system clock source */
  687. RCC->CFGR &= (uint32_t)((uint32_t) ~(RCC_CFGR_SW));
  688. RCC->CFGR |= RCC_CFGR_SW_PLL;
  689. /* Wait till the main PLL is used as system clock source */
  690. while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)
  691. ;
  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_3WS;
  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. }
  752. else
  753. { /* If HSE fails to start-up, the application will have wrong clock
  754. configuration. User can add here some code to deal with this error */
  755. }
  756. #else /* HSI will be used as PLL clock source */
  757. /* Select regulator voltage output Scale 1 mode */
  758. RCC->APB1ENR |= RCC_APB1ENR_PWREN;
  759. PWR->CR |= PWR_CR_VOS;
  760. /* HCLK = SYSCLK / 1*/
  761. RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
  762. /* PCLK2 = HCLK / 2*/
  763. RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
  764. /* PCLK1 = HCLK / 4*/
  765. RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
  766. /* Configure the main PLL */
  767. RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) | (PLL_Q << 24);
  768. /* Enable the main PLL */
  769. RCC->CR |= RCC_CR_PLLON;
  770. /* Wait till the main PLL is ready */
  771. while ((RCC->CR & RCC_CR_PLLRDY) == 0)
  772. {
  773. }
  774. /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
  775. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_3WS;
  776. /* Select the main PLL as system clock source */
  777. RCC->CFGR &= (uint32_t)((uint32_t) ~(RCC_CFGR_SW));
  778. RCC->CFGR |= RCC_CFGR_SW_PLL;
  779. /* Wait till the main PLL is used as system clock source */
  780. while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)
  781. ;
  782. {
  783. }
  784. #endif /* USE_HSE_BYPASS */
  785. #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F469_479xx */
  786. }
  787. #if defined(DATA_IN_ExtSRAM) && defined(DATA_IN_ExtSDRAM)
  788. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  789. defined(STM32F469xx) || defined(STM32F479xx)
  790. /**
  791. * @brief Setup the external memory controller.
  792. * Called in startup_stm32f4xx.s before jump to main.
  793. * This function configures the external memories (SRAM/SDRAM)
  794. * This SRAM/SDRAM will be used as program data memory (including heap and stack).
  795. * @param None
  796. * @retval None
  797. */
  798. void SystemInit_ExtMemCtl(void)
  799. {
  800. __IO uint32_t tmp = 0x00;
  801. register uint32_t tmpreg = 0, timeout = 0xFFFF;
  802. register uint32_t index;
  803. /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */
  804. RCC->AHB1ENR |= 0x000001F8;
  805. /* Delay after an RCC peripheral clock enabling */
  806. tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
  807. /* Connect PDx pins to FMC Alternate function */
  808. GPIOD->AFR[0] = 0x00CCC0CC;
  809. GPIOD->AFR[1] = 0xCCCCCCCC;
  810. /* Configure PDx pins in Alternate function mode */
  811. GPIOD->MODER = 0xAAAA0A8A;
  812. /* Configure PDx pins speed to 100 MHz */
  813. GPIOD->OSPEEDR = 0xFFFF0FCF;
  814. /* Configure PDx pins Output type to push-pull */
  815. GPIOD->OTYPER = 0x00000000;
  816. /* No pull-up, pull-down for PDx pins */
  817. GPIOD->PUPDR = 0x00000000;
  818. /* Connect PEx pins to FMC Alternate function */
  819. GPIOE->AFR[0] = 0xC00CC0CC;
  820. GPIOE->AFR[1] = 0xCCCCCCCC;
  821. /* Configure PEx pins in Alternate function mode */
  822. GPIOE->MODER = 0xAAAA828A;
  823. /* Configure PEx pins speed to 100 MHz */
  824. GPIOE->OSPEEDR = 0xFFFFC3CF;
  825. /* Configure PEx pins Output type to push-pull */
  826. GPIOE->OTYPER = 0x00000000;
  827. /* No pull-up, pull-down for PEx pins */
  828. GPIOE->PUPDR = 0x00000000;
  829. /* Connect PFx pins to FMC Alternate function */
  830. GPIOF->AFR[0] = 0xCCCCCCCC;
  831. GPIOF->AFR[1] = 0xCCCCCCCC;
  832. /* Configure PFx pins in Alternate function mode */
  833. GPIOF->MODER = 0xAA800AAA;
  834. /* Configure PFx pins speed to 50 MHz */
  835. GPIOF->OSPEEDR = 0xAA800AAA;
  836. /* Configure PFx pins Output type to push-pull */
  837. GPIOF->OTYPER = 0x00000000;
  838. /* No pull-up, pull-down for PFx pins */
  839. GPIOF->PUPDR = 0x00000000;
  840. /* Connect PGx pins to FMC Alternate function */
  841. GPIOG->AFR[0] = 0xCCCCCCCC;
  842. GPIOG->AFR[1] = 0xCCCCCCCC;
  843. /* Configure PGx pins in Alternate function mode */
  844. GPIOG->MODER = 0xAAAAAAAA;
  845. /* Configure PGx pins speed to 50 MHz */
  846. GPIOG->OSPEEDR = 0xAAAAAAAA;
  847. /* Configure PGx pins Output type to push-pull */
  848. GPIOG->OTYPER = 0x00000000;
  849. /* No pull-up, pull-down for PGx pins */
  850. GPIOG->PUPDR = 0x00000000;
  851. /* Connect PHx pins to FMC Alternate function */
  852. GPIOH->AFR[0] = 0x00C0CC00;
  853. GPIOH->AFR[1] = 0xCCCCCCCC;
  854. /* Configure PHx pins in Alternate function mode */
  855. GPIOH->MODER = 0xAAAA08A0;
  856. /* Configure PHx pins speed to 50 MHz */
  857. GPIOH->OSPEEDR = 0xAAAA08A0;
  858. /* Configure PHx pins Output type to push-pull */
  859. GPIOH->OTYPER = 0x00000000;
  860. /* No pull-up, pull-down for PHx pins */
  861. GPIOH->PUPDR = 0x00000000;
  862. /* Connect PIx pins to FMC Alternate function */
  863. GPIOI->AFR[0] = 0xCCCCCCCC;
  864. GPIOI->AFR[1] = 0x00000CC0;
  865. /* Configure PIx pins in Alternate function mode */
  866. GPIOI->MODER = 0x0028AAAA;
  867. /* Configure PIx pins speed to 50 MHz */
  868. GPIOI->OSPEEDR = 0x0028AAAA;
  869. /* Configure PIx pins Output type to push-pull */
  870. GPIOI->OTYPER = 0x00000000;
  871. /* No pull-up, pull-down for PIx pins */
  872. GPIOI->PUPDR = 0x00000000;
  873. /*-- FMC Configuration -------------------------------------------------------*/
  874. /* Enable the FMC interface clock */
  875. RCC->AHB3ENR |= 0x00000001;
  876. /* Delay after an RCC peripheral clock enabling */
  877. tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
  878. FMC_Bank5_6->SDCR[0] = 0x000019E4;
  879. FMC_Bank5_6->SDTR[0] = 0x01115351;
  880. /* SDRAM initialization sequence */
  881. /* Clock enable command */
  882. FMC_Bank5_6->SDCMR = 0x00000011;
  883. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  884. while ((tmpreg != 0) && (timeout-- > 0))
  885. {
  886. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  887. }
  888. /* Delay */
  889. for (index = 0; index < 1000; index++)
  890. ;
  891. /* PALL command */
  892. FMC_Bank5_6->SDCMR = 0x00000012;
  893. timeout = 0xFFFF;
  894. while ((tmpreg != 0) && (timeout-- > 0))
  895. {
  896. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  897. }
  898. /* Auto refresh command */
  899. FMC_Bank5_6->SDCMR = 0x00000073;
  900. timeout = 0xFFFF;
  901. while ((tmpreg != 0) && (timeout-- > 0))
  902. {
  903. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  904. }
  905. /* MRD register program */
  906. FMC_Bank5_6->SDCMR = 0x00046014;
  907. timeout = 0xFFFF;
  908. while ((tmpreg != 0) && (timeout-- > 0))
  909. {
  910. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  911. }
  912. /* Set refresh count */
  913. tmpreg = FMC_Bank5_6->SDRTR;
  914. FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C << 1));
  915. /* Disable write protection */
  916. tmpreg = FMC_Bank5_6->SDCR[0];
  917. FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
  918. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  919. /* Configure and enable Bank1_SRAM2 */
  920. FMC_Bank1->BTCR[2] = 0x00001011;
  921. FMC_Bank1->BTCR[3] = 0x00000201;
  922. FMC_Bank1E->BWTR[2] = 0x0fffffff;
  923. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  924. #if defined(STM32F469xx) || defined(STM32F479xx)
  925. /* Configure and enable Bank1_SRAM2 */
  926. FMC_Bank1->BTCR[2] = 0x00001091;
  927. FMC_Bank1->BTCR[3] = 0x00110212;
  928. FMC_Bank1E->BWTR[2] = 0x0fffffff;
  929. #endif /* STM32F469xx || STM32F479xx */
  930. (void)(tmp);
  931. }
  932. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  933. #elif defined(DATA_IN_ExtSRAM)
  934. /**
  935. * @brief Setup the external memory controller. Called in startup_stm32f4xx.s
  936. * before jump to __main
  937. * @param None
  938. * @retval None
  939. */
  940. /**
  941. * @brief Setup the external memory controller.
  942. * Called in startup_stm32f4xx.s before jump to main.
  943. * This function configures the external SRAM mounted on STM324xG_EVAL/STM324x7I boards
  944. * This SRAM will be used as program data memory (including heap and stack).
  945. * @param None
  946. * @retval None
  947. */
  948. void SystemInit_ExtMemCtl(void)
  949. {
  950. /*-- GPIOs Configuration -----------------------------------------------------*/
  951. /*
  952. +-------------------+--------------------+------------------+--------------+
  953. + SRAM pins assignment +
  954. +-------------------+--------------------+------------------+--------------+
  955. | PD0 <-> FMC_D2 | PE0 <-> FMC_NBL0 | PF0 <-> FMC_A0 | PG0 <-> FMC_A10 |
  956. | PD1 <-> FMC_D3 | PE1 <-> FMC_NBL1 | PF1 <-> FMC_A1 | PG1 <-> FMC_A11 |
  957. | PD4 <-> FMC_NOE | PE3 <-> FMC_A19 | PF2 <-> FMC_A2 | PG2 <-> FMC_A12 |
  958. | PD5 <-> FMC_NWE | PE4 <-> FMC_A20 | PF3 <-> FMC_A3 | PG3 <-> FMC_A13 |
  959. | PD8 <-> FMC_D13 | PE7 <-> FMC_D4 | PF4 <-> FMC_A4 | PG4 <-> FMC_A14 |
  960. | PD9 <-> FMC_D14 | PE8 <-> FMC_D5 | PF5 <-> FMC_A5 | PG5 <-> FMC_A15 |
  961. | PD10 <-> FMC_D15 | PE9 <-> FMC_D6 | PF12 <-> FMC_A6 | PG9 <-> FMC_NE2 |
  962. | PD11 <-> FMC_A16 | PE10 <-> FMC_D7 | PF13 <-> FMC_A7 |-----------------+
  963. | PD12 <-> FMC_A17 | PE11 <-> FMC_D8 | PF14 <-> FMC_A8 |
  964. | PD13 <-> FMC_A18 | PE12 <-> FMC_D9 | PF15 <-> FMC_A9 |
  965. | PD14 <-> FMC_D0 | PE13 <-> FMC_D10 |-----------------+
  966. | PD15 <-> FMC_D1 | PE14 <-> FMC_D11 |
  967. | | PE15 <-> FMC_D12 |
  968. +------------------+------------------+
  969. */
  970. /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
  971. RCC->AHB1ENR |= 0x00000078;
  972. /* Connect PDx pins to FMC Alternate function */
  973. GPIOD->AFR[0] = 0x00cc00cc;
  974. GPIOD->AFR[1] = 0xcccccccc;
  975. /* Configure PDx pins in Alternate function mode */
  976. GPIOD->MODER = 0xaaaa0a0a;
  977. /* Configure PDx pins speed to 100 MHz */
  978. GPIOD->OSPEEDR = 0xffff0f0f;
  979. /* Configure PDx pins Output type to push-pull */
  980. GPIOD->OTYPER = 0x00000000;
  981. /* No pull-up, pull-down for PDx pins */
  982. GPIOD->PUPDR = 0x00000000;
  983. /* Connect PEx pins to FMC Alternate function */
  984. GPIOE->AFR[0] = 0xcccccccc;
  985. GPIOE->AFR[1] = 0xcccccccc;
  986. /* Configure PEx pins in Alternate function mode */
  987. GPIOE->MODER = 0xaaaaaaaa;
  988. /* Configure PEx pins speed to 100 MHz */
  989. GPIOE->OSPEEDR = 0xffffffff;
  990. /* Configure PEx pins Output type to push-pull */
  991. GPIOE->OTYPER = 0x00000000;
  992. /* No pull-up, pull-down for PEx pins */
  993. GPIOE->PUPDR = 0x00000000;
  994. /* Connect PFx pins to FMC Alternate function */
  995. GPIOF->AFR[0] = 0x00cccccc;
  996. GPIOF->AFR[1] = 0xcccc0000;
  997. /* Configure PFx pins in Alternate function mode */
  998. GPIOF->MODER = 0xaa000aaa;
  999. /* Configure PFx pins speed to 100 MHz */
  1000. GPIOF->OSPEEDR = 0xff000fff;
  1001. /* Configure PFx pins Output type to push-pull */
  1002. GPIOF->OTYPER = 0x00000000;
  1003. /* No pull-up, pull-down for PFx pins */
  1004. GPIOF->PUPDR = 0x00000000;
  1005. /* Connect PGx pins to FMC Alternate function */
  1006. GPIOG->AFR[0] = 0x00cccccc;
  1007. GPIOG->AFR[1] = 0x000000c0;
  1008. /* Configure PGx pins in Alternate function mode */
  1009. GPIOG->MODER = 0x00080aaa;
  1010. /* Configure PGx pins speed to 100 MHz */
  1011. GPIOG->OSPEEDR = 0x000c0fff;
  1012. /* Configure PGx pins Output type to push-pull */
  1013. GPIOG->OTYPER = 0x00000000;
  1014. /* No pull-up, pull-down for PGx pins */
  1015. GPIOG->PUPDR = 0x00000000;
  1016. /*-- FMC Configuration ------------------------------------------------------*/
  1017. /* Enable the FMC/FSMC interface clock */
  1018. RCC->AHB3ENR |= 0x00000001;
  1019. #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
  1020. /* Configure and enable Bank1_SRAM2 */
  1021. FMC_Bank1->BTCR[2] = 0x00001011;
  1022. FMC_Bank1->BTCR[3] = 0x00000201;
  1023. FMC_Bank1E->BWTR[2] = 0x0fffffff;
  1024. #endif /* STM32F427_437xx || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
  1025. #if defined(STM32F40_41xxx)
  1026. /* Configure and enable Bank1_SRAM2 */
  1027. FSMC_Bank1->BTCR[2] = 0x00001011;
  1028. FSMC_Bank1->BTCR[3] = 0x00000201;
  1029. FSMC_Bank1E->BWTR[2] = 0x0fffffff;
  1030. #endif /* STM32F40_41xxx */
  1031. /*
  1032. Bank1_SRAM2 is configured as follow:
  1033. In case of FSMC configuration
  1034. NORSRAMTimingStructure.FSMC_AddressSetupTime = 1;
  1035. NORSRAMTimingStructure.FSMC_AddressHoldTime = 0;
  1036. NORSRAMTimingStructure.FSMC_DataSetupTime = 2;
  1037. NORSRAMTimingStructure.FSMC_BusTurnAroundDuration = 0;
  1038. NORSRAMTimingStructure.FSMC_CLKDivision = 0;
  1039. NORSRAMTimingStructure.FSMC_DataLatency = 0;
  1040. NORSRAMTimingStructure.FSMC_AccessMode = FMC_AccessMode_A;
  1041. FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
  1042. FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
  1043. FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
  1044. FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
  1045. FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
  1046. FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
  1047. FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
  1048. FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
  1049. FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
  1050. FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
  1051. FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
  1052. FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
  1053. FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
  1054. FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &NORSRAMTimingStructure;
  1055. FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &NORSRAMTimingStructure;
  1056. In case of FMC configuration
  1057. NORSRAMTimingStructure.FMC_AddressSetupTime = 1;
  1058. NORSRAMTimingStructure.FMC_AddressHoldTime = 0;
  1059. NORSRAMTimingStructure.FMC_DataSetupTime = 2;
  1060. NORSRAMTimingStructure.FMC_BusTurnAroundDuration = 0;
  1061. NORSRAMTimingStructure.FMC_CLKDivision = 0;
  1062. NORSRAMTimingStructure.FMC_DataLatency = 0;
  1063. NORSRAMTimingStructure.FMC_AccessMode = FMC_AccessMode_A;
  1064. FMC_NORSRAMInitStructure.FMC_Bank = FMC_Bank1_NORSRAM2;
  1065. FMC_NORSRAMInitStructure.FMC_DataAddressMux = FMC_DataAddressMux_Disable;
  1066. FMC_NORSRAMInitStructure.FMC_MemoryType = FMC_MemoryType_SRAM;
  1067. FMC_NORSRAMInitStructure.FMC_MemoryDataWidth = FMC_MemoryDataWidth_16b;
  1068. FMC_NORSRAMInitStructure.FMC_BurstAccessMode = FMC_BurstAccessMode_Disable;
  1069. FMC_NORSRAMInitStructure.FMC_AsynchronousWait = FMC_AsynchronousWait_Disable;
  1070. FMC_NORSRAMInitStructure.FMC_WaitSignalPolarity = FMC_WaitSignalPolarity_Low;
  1071. FMC_NORSRAMInitStructure.FMC_WrapMode = FMC_WrapMode_Disable;
  1072. FMC_NORSRAMInitStructure.FMC_WaitSignalActive = FMC_WaitSignalActive_BeforeWaitState;
  1073. FMC_NORSRAMInitStructure.FMC_WriteOperation = FMC_WriteOperation_Enable;
  1074. FMC_NORSRAMInitStructure.FMC_WaitSignal = FMC_WaitSignal_Disable;
  1075. FMC_NORSRAMInitStructure.FMC_ExtendedMode = FMC_ExtendedMode_Disable;
  1076. FMC_NORSRAMInitStructure.FMC_WriteBurst = FMC_WriteBurst_Disable;
  1077. FMC_NORSRAMInitStructure.FMC_ContinousClock = FMC_CClock_SyncOnly;
  1078. FMC_NORSRAMInitStructure.FMC_ReadWriteTimingStruct = &NORSRAMTimingStructure;
  1079. FMC_NORSRAMInitStructure.FMC_WriteTimingStruct = &NORSRAMTimingStructure;
  1080. */
  1081. }
  1082. #elif defined(DATA_IN_ExtSDRAM)
  1083. /**
  1084. * @brief Setup the external memory controller.
  1085. * Called in startup_stm32f4xx.s before jump to main.
  1086. * This function configures the external SDRAM mounted on STM324x9I_EVAL board
  1087. * This SDRAM will be used as program data memory (including heap and stack).
  1088. * @param None
  1089. * @retval None
  1090. */
  1091. void SystemInit_ExtMemCtl(void)
  1092. {
  1093. register uint32_t tmpreg = 0, timeout = 0xFFFF;
  1094. register uint32_t index;
  1095. /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
  1096. clock */
  1097. RCC->AHB1ENR |= 0x000001FC;
  1098. /* Connect PCx pins to FMC Alternate function */
  1099. GPIOC->AFR[0] = 0x0000000c;
  1100. GPIOC->AFR[1] = 0x00007700;
  1101. /* Configure PCx pins in Alternate function mode */
  1102. GPIOC->MODER = 0x00a00002;
  1103. /* Configure PCx pins speed to 50 MHz */
  1104. GPIOC->OSPEEDR = 0x00a00002;
  1105. /* Configure PCx pins Output type to push-pull */
  1106. GPIOC->OTYPER = 0x00000000;
  1107. /* No pull-up, pull-down for PCx pins */
  1108. GPIOC->PUPDR = 0x00500000;
  1109. /* Connect PDx pins to FMC Alternate function */
  1110. GPIOD->AFR[0] = 0x000000CC;
  1111. GPIOD->AFR[1] = 0xCC000CCC;
  1112. /* Configure PDx pins in Alternate function mode */
  1113. GPIOD->MODER = 0xA02A000A;
  1114. /* Configure PDx pins speed to 50 MHz */
  1115. GPIOD->OSPEEDR = 0xA02A000A;
  1116. /* Configure PDx pins Output type to push-pull */
  1117. GPIOD->OTYPER = 0x00000000;
  1118. /* No pull-up, pull-down for PDx pins */
  1119. GPIOD->PUPDR = 0x00000000;
  1120. /* Connect PEx pins to FMC Alternate function */
  1121. GPIOE->AFR[0] = 0xC00000CC;
  1122. GPIOE->AFR[1] = 0xCCCCCCCC;
  1123. /* Configure PEx pins in Alternate function mode */
  1124. GPIOE->MODER = 0xAAAA800A;
  1125. /* Configure PEx pins speed to 50 MHz */
  1126. GPIOE->OSPEEDR = 0xAAAA800A;
  1127. /* Configure PEx pins Output type to push-pull */
  1128. GPIOE->OTYPER = 0x00000000;
  1129. /* No pull-up, pull-down for PEx pins */
  1130. GPIOE->PUPDR = 0x00000000;
  1131. /* Connect PFx pins to FMC Alternate function */
  1132. GPIOF->AFR[0] = 0xcccccccc;
  1133. GPIOF->AFR[1] = 0xcccccccc;
  1134. /* Configure PFx pins in Alternate function mode */
  1135. GPIOF->MODER = 0xAA800AAA;
  1136. /* Configure PFx pins speed to 50 MHz */
  1137. GPIOF->OSPEEDR = 0xAA800AAA;
  1138. /* Configure PFx pins Output type to push-pull */
  1139. GPIOF->OTYPER = 0x00000000;
  1140. /* No pull-up, pull-down for PFx pins */
  1141. GPIOF->PUPDR = 0x00000000;
  1142. /* Connect PGx pins to FMC Alternate function */
  1143. GPIOG->AFR[0] = 0xcccccccc;
  1144. GPIOG->AFR[1] = 0xcccccccc;
  1145. /* Configure PGx pins in Alternate function mode */
  1146. GPIOG->MODER = 0xaaaaaaaa;
  1147. /* Configure PGx pins speed to 50 MHz */
  1148. GPIOG->OSPEEDR = 0xaaaaaaaa;
  1149. /* Configure PGx pins Output type to push-pull */
  1150. GPIOG->OTYPER = 0x00000000;
  1151. /* No pull-up, pull-down for PGx pins */
  1152. GPIOG->PUPDR = 0x00000000;
  1153. /* Connect PHx pins to FMC Alternate function */
  1154. GPIOH->AFR[0] = 0x00C0CC00;
  1155. GPIOH->AFR[1] = 0xCCCCCCCC;
  1156. /* Configure PHx pins in Alternate function mode */
  1157. GPIOH->MODER = 0xAAAA08A0;
  1158. /* Configure PHx pins speed to 50 MHz */
  1159. GPIOH->OSPEEDR = 0xAAAA08A0;
  1160. /* Configure PHx pins Output type to push-pull */
  1161. GPIOH->OTYPER = 0x00000000;
  1162. /* No pull-up, pull-down for PHx pins */
  1163. GPIOH->PUPDR = 0x00000000;
  1164. /* Connect PIx pins to FMC Alternate function */
  1165. GPIOI->AFR[0] = 0xCCCCCCCC;
  1166. GPIOI->AFR[1] = 0x00000CC0;
  1167. /* Configure PIx pins in Alternate function mode */
  1168. GPIOI->MODER = 0x0028AAAA;
  1169. /* Configure PIx pins speed to 50 MHz */
  1170. GPIOI->OSPEEDR = 0x0028AAAA;
  1171. /* Configure PIx pins Output type to push-pull */
  1172. GPIOI->OTYPER = 0x00000000;
  1173. /* No pull-up, pull-down for PIx pins */
  1174. GPIOI->PUPDR = 0x00000000;
  1175. /*-- FMC Configuration ------------------------------------------------------*/
  1176. /* Enable the FMC interface clock */
  1177. RCC->AHB3ENR |= 0x00000001;
  1178. /* Configure and enable SDRAM bank1 */
  1179. FMC_Bank5_6->SDCR[0] = 0x000039D0;
  1180. FMC_Bank5_6->SDTR[0] = 0x01115351;
  1181. /* SDRAM initialization sequence */
  1182. /* Clock enable command */
  1183. FMC_Bank5_6->SDCMR = 0x00000011;
  1184. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1185. while ((tmpreg != 0) & (timeout-- > 0))
  1186. {
  1187. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1188. }
  1189. /* Delay */
  1190. for (index = 0; index < 1000; index++)
  1191. ;
  1192. /* PALL command */
  1193. FMC_Bank5_6->SDCMR = 0x00000012;
  1194. timeout = 0xFFFF;
  1195. while ((tmpreg != 0) & (timeout-- > 0))
  1196. {
  1197. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1198. }
  1199. /* Auto refresh command */
  1200. FMC_Bank5_6->SDCMR = 0x00000073;
  1201. timeout = 0xFFFF;
  1202. while ((tmpreg != 0) & (timeout-- > 0))
  1203. {
  1204. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1205. }
  1206. /* MRD register program */
  1207. FMC_Bank5_6->SDCMR = 0x00046014;
  1208. timeout = 0xFFFF;
  1209. while ((tmpreg != 0) & (timeout-- > 0))
  1210. {
  1211. tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
  1212. }
  1213. /* Set refresh count */
  1214. tmpreg = FMC_Bank5_6->SDRTR;
  1215. FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C << 1));
  1216. /* Disable write protection */
  1217. tmpreg = FMC_Bank5_6->SDCR[0];
  1218. FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
  1219. /*
  1220. Bank1_SDRAM is configured as follow:
  1221. FMC_SDRAMTimingInitStructure.FMC_LoadToActiveDelay = 2;
  1222. FMC_SDRAMTimingInitStructure.FMC_ExitSelfRefreshDelay = 6;
  1223. FMC_SDRAMTimingInitStructure.FMC_SelfRefreshTime = 4;
  1224. FMC_SDRAMTimingInitStructure.FMC_RowCycleDelay = 6;
  1225. FMC_SDRAMTimingInitStructure.FMC_WriteRecoveryTime = 2;
  1226. FMC_SDRAMTimingInitStructure.FMC_RPDelay = 2;
  1227. FMC_SDRAMTimingInitStructure.FMC_RCDDelay = 2;
  1228. FMC_SDRAMInitStructure.FMC_Bank = SDRAM_BANK;
  1229. FMC_SDRAMInitStructure.FMC_ColumnBitsNumber = FMC_ColumnBits_Number_8b;
  1230. FMC_SDRAMInitStructure.FMC_RowBitsNumber = FMC_RowBits_Number_11b;
  1231. FMC_SDRAMInitStructure.FMC_SDMemoryDataWidth = FMC_SDMemory_Width_16b;
  1232. FMC_SDRAMInitStructure.FMC_InternalBankNumber = FMC_InternalBank_Number_4;
  1233. FMC_SDRAMInitStructure.FMC_CASLatency = FMC_CAS_Latency_3;
  1234. FMC_SDRAMInitStructure.FMC_WriteProtection = FMC_Write_Protection_Disable;
  1235. FMC_SDRAMInitStructure.FMC_SDClockPeriod = FMC_SDClock_Period_2;
  1236. FMC_SDRAMInitStructure.FMC_ReadBurst = FMC_Read_Burst_disable;
  1237. FMC_SDRAMInitStructure.FMC_ReadPipeDelay = FMC_ReadPipe_Delay_1;
  1238. FMC_SDRAMInitStructure.FMC_SDRAMTimingStruct = &FMC_SDRAMTimingInitStructure;
  1239. */
  1240. }
  1241. #endif /* DATA_IN_ExtSDRAM && DATA_IN_ExtSRAM */
  1242. /**
  1243. * @}
  1244. */
  1245. /**
  1246. * @}
  1247. */
  1248. /**
  1249. * @}
  1250. */