stm32f411/stm32f411e-disco/Src/system_stm32f4xx.c
Go to the documentation of this file.
1 
64 #include "stm32f4xx.h"
65 
66 #if !defined (HSE_VALUE)
67  #define HSE_VALUE ((uint32_t)25000000)
68 #endif /* HSE_VALUE */
69 
70 #if !defined (HSI_VALUE)
71  #define HSI_VALUE ((uint32_t)16000000)
72 #endif /* HSI_VALUE */
73 
90 /************************* Miscellaneous Configuration ************************/
92 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
93  || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
94  || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
95 /* #define DATA_IN_ExtSRAM */
96 #endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\
97  STM32F412Zx || STM32F412Vx */
98 
99 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
100  || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
101 /* #define DATA_IN_ExtSDRAM */
102 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
103  STM32F479xx */
104 
107 /* #define VECT_TAB_SRAM */
108 #define VECT_TAB_OFFSET 0x00
110 /******************************************************************************/
111 
127  /* This variable is updated in three ways:
128  1) by calling CMSIS function SystemCoreClockUpdate()
129  2) by calling HAL API function HAL_RCC_GetHCLKFreq()
130  3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
131  Note: If you use this function to configure the system clock; then there
132  is no need to call the 2 first functions listed above, since SystemCoreClock
133  variable is updated automatically.
134  */
135 uint32_t SystemCoreClock = 16000000;
136 const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
137 const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
146 #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
147  static void SystemInit_ExtMemCtl(void);
148 #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
149 
165 void SystemInit(void)
166 {
167  /* FPU settings ------------------------------------------------------------*/
168  #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
169  SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
170  #endif
171 
172 #if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
173  SystemInit_ExtMemCtl();
174 #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
175 
176  /* Configure the Vector Table location add offset address ------------------*/
177 #ifdef VECT_TAB_SRAM
178  SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
179 #else
180  SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
181 #endif
182 }
183 
220 void SystemCoreClockUpdate(void)
221 {
222  uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
223 
224  /* Get SYSCLK source -------------------------------------------------------*/
225  tmp = RCC->CFGR & RCC_CFGR_SWS;
226 
227  switch (tmp)
228  {
229  case 0x00: /* HSI used as system clock source */
231  break;
232  case 0x04: /* HSE used as system clock source */
234  break;
235  case 0x08: /* PLL used as system clock source */
236 
237  /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
238  SYSCLK = PLL_VCO / PLL_P
239  */
240  pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
241  pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
242 
243  if (pllsource != 0)
244  {
245  /* HSE used as PLL clock source */
246  pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
247  }
248  else
249  {
250  /* HSI used as PLL clock source */
251  pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
252  }
253 
254  pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
255  SystemCoreClock = pllvco/pllp;
256  break;
257  default:
259  break;
260  }
261  /* Compute HCLK frequency --------------------------------------------------*/
262  /* Get HCLK prescaler */
263  tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
264  /* HCLK frequency */
265  SystemCoreClock >>= tmp;
266 }
267 
268 #if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM)
269 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
270  || defined(STM32F469xx) || defined(STM32F479xx)
271 
279 void SystemInit_ExtMemCtl(void)
280 {
281  __IO uint32_t tmp = 0x00;
282 
283  register uint32_t tmpreg = 0, timeout = 0xFFFF;
284  register __IO uint32_t index;
285 
286  /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */
287  RCC->AHB1ENR |= 0x000001F8;
288 
289  /* Delay after an RCC peripheral clock enabling */
290  tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
291 
292  /* Connect PDx pins to FMC Alternate function */
293  GPIOD->AFR[0] = 0x00CCC0CC;
294  GPIOD->AFR[1] = 0xCCCCCCCC;
295  /* Configure PDx pins in Alternate function mode */
296  GPIOD->MODER = 0xAAAA0A8A;
297  /* Configure PDx pins speed to 100 MHz */
298  GPIOD->OSPEEDR = 0xFFFF0FCF;
299  /* Configure PDx pins Output type to push-pull */
300  GPIOD->OTYPER = 0x00000000;
301  /* No pull-up, pull-down for PDx pins */
302  GPIOD->PUPDR = 0x00000000;
303 
304  /* Connect PEx pins to FMC Alternate function */
305  GPIOE->AFR[0] = 0xC00CC0CC;
306  GPIOE->AFR[1] = 0xCCCCCCCC;
307  /* Configure PEx pins in Alternate function mode */
308  GPIOE->MODER = 0xAAAA828A;
309  /* Configure PEx pins speed to 100 MHz */
310  GPIOE->OSPEEDR = 0xFFFFC3CF;
311  /* Configure PEx pins Output type to push-pull */
312  GPIOE->OTYPER = 0x00000000;
313  /* No pull-up, pull-down for PEx pins */
314  GPIOE->PUPDR = 0x00000000;
315 
316  /* Connect PFx pins to FMC Alternate function */
317  GPIOF->AFR[0] = 0xCCCCCCCC;
318  GPIOF->AFR[1] = 0xCCCCCCCC;
319  /* Configure PFx pins in Alternate function mode */
320  GPIOF->MODER = 0xAA800AAA;
321  /* Configure PFx pins speed to 50 MHz */
322  GPIOF->OSPEEDR = 0xAA800AAA;
323  /* Configure PFx pins Output type to push-pull */
324  GPIOF->OTYPER = 0x00000000;
325  /* No pull-up, pull-down for PFx pins */
326  GPIOF->PUPDR = 0x00000000;
327 
328  /* Connect PGx pins to FMC Alternate function */
329  GPIOG->AFR[0] = 0xCCCCCCCC;
330  GPIOG->AFR[1] = 0xCCCCCCCC;
331  /* Configure PGx pins in Alternate function mode */
332  GPIOG->MODER = 0xAAAAAAAA;
333  /* Configure PGx pins speed to 50 MHz */
334  GPIOG->OSPEEDR = 0xAAAAAAAA;
335  /* Configure PGx pins Output type to push-pull */
336  GPIOG->OTYPER = 0x00000000;
337  /* No pull-up, pull-down for PGx pins */
338  GPIOG->PUPDR = 0x00000000;
339 
340  /* Connect PHx pins to FMC Alternate function */
341  GPIOH->AFR[0] = 0x00C0CC00;
342  GPIOH->AFR[1] = 0xCCCCCCCC;
343  /* Configure PHx pins in Alternate function mode */
344  GPIOH->MODER = 0xAAAA08A0;
345  /* Configure PHx pins speed to 50 MHz */
346  GPIOH->OSPEEDR = 0xAAAA08A0;
347  /* Configure PHx pins Output type to push-pull */
348  GPIOH->OTYPER = 0x00000000;
349  /* No pull-up, pull-down for PHx pins */
350  GPIOH->PUPDR = 0x00000000;
351 
352  /* Connect PIx pins to FMC Alternate function */
353  GPIOI->AFR[0] = 0xCCCCCCCC;
354  GPIOI->AFR[1] = 0x00000CC0;
355  /* Configure PIx pins in Alternate function mode */
356  GPIOI->MODER = 0x0028AAAA;
357  /* Configure PIx pins speed to 50 MHz */
358  GPIOI->OSPEEDR = 0x0028AAAA;
359  /* Configure PIx pins Output type to push-pull */
360  GPIOI->OTYPER = 0x00000000;
361  /* No pull-up, pull-down for PIx pins */
362  GPIOI->PUPDR = 0x00000000;
363 
364 /*-- FMC Configuration -------------------------------------------------------*/
365  /* Enable the FMC interface clock */
366  RCC->AHB3ENR |= 0x00000001;
367  /* Delay after an RCC peripheral clock enabling */
368  tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
369 
370  FMC_Bank5_6->SDCR[0] = 0x000019E4;
371  FMC_Bank5_6->SDTR[0] = 0x01115351;
372 
373  /* SDRAM initialization sequence */
374  /* Clock enable command */
375  FMC_Bank5_6->SDCMR = 0x00000011;
376  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
377  while((tmpreg != 0) && (timeout-- > 0))
378  {
379  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
380  }
381 
382  /* Delay */
383  for (index = 0; index<1000; index++);
384 
385  /* PALL command */
386  FMC_Bank5_6->SDCMR = 0x00000012;
387  timeout = 0xFFFF;
388  while((tmpreg != 0) && (timeout-- > 0))
389  {
390  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
391  }
392 
393  /* Auto refresh command */
394  FMC_Bank5_6->SDCMR = 0x00000073;
395  timeout = 0xFFFF;
396  while((tmpreg != 0) && (timeout-- > 0))
397  {
398  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
399  }
400 
401  /* MRD register program */
402  FMC_Bank5_6->SDCMR = 0x00046014;
403  timeout = 0xFFFF;
404  while((tmpreg != 0) && (timeout-- > 0))
405  {
406  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
407  }
408 
409  /* Set refresh count */
410  tmpreg = FMC_Bank5_6->SDRTR;
411  FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
412 
413  /* Disable write protection */
414  tmpreg = FMC_Bank5_6->SDCR[0];
415  FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
416 
417 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
418  /* Configure and enable Bank1_SRAM2 */
419  FMC_Bank1->BTCR[2] = 0x00001011;
420  FMC_Bank1->BTCR[3] = 0x00000201;
421  FMC_Bank1E->BWTR[2] = 0x0fffffff;
422 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
423 #if defined(STM32F469xx) || defined(STM32F479xx)
424  /* Configure and enable Bank1_SRAM2 */
425  FMC_Bank1->BTCR[2] = 0x00001091;
426  FMC_Bank1->BTCR[3] = 0x00110212;
427  FMC_Bank1E->BWTR[2] = 0x0fffffff;
428 #endif /* STM32F469xx || STM32F479xx */
429 
430  (void)(tmp);
431 }
432 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
433 #elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
434 
442 void SystemInit_ExtMemCtl(void)
443 {
444  __IO uint32_t tmp = 0x00;
445 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
446  || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
447 #if defined (DATA_IN_ExtSDRAM)
448  register uint32_t tmpreg = 0, timeout = 0xFFFF;
449  register __IO uint32_t index;
450 
451 #if defined(STM32F446xx)
452  /* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface
453  clock */
454  RCC->AHB1ENR |= 0x0000007D;
455 #else
456  /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
457  clock */
458  RCC->AHB1ENR |= 0x000001F8;
459 #endif /* STM32F446xx */
460  /* Delay after an RCC peripheral clock enabling */
461  tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
462 
463 #if defined(STM32F446xx)
464  /* Connect PAx pins to FMC Alternate function */
465  GPIOA->AFR[0] |= 0xC0000000;
466  GPIOA->AFR[1] |= 0x00000000;
467  /* Configure PDx pins in Alternate function mode */
468  GPIOA->MODER |= 0x00008000;
469  /* Configure PDx pins speed to 50 MHz */
470  GPIOA->OSPEEDR |= 0x00008000;
471  /* Configure PDx pins Output type to push-pull */
472  GPIOA->OTYPER |= 0x00000000;
473  /* No pull-up, pull-down for PDx pins */
474  GPIOA->PUPDR |= 0x00000000;
475 
476  /* Connect PCx pins to FMC Alternate function */
477  GPIOC->AFR[0] |= 0x00CC0000;
478  GPIOC->AFR[1] |= 0x00000000;
479  /* Configure PDx pins in Alternate function mode */
480  GPIOC->MODER |= 0x00000A00;
481  /* Configure PDx pins speed to 50 MHz */
482  GPIOC->OSPEEDR |= 0x00000A00;
483  /* Configure PDx pins Output type to push-pull */
484  GPIOC->OTYPER |= 0x00000000;
485  /* No pull-up, pull-down for PDx pins */
486  GPIOC->PUPDR |= 0x00000000;
487 #endif /* STM32F446xx */
488 
489  /* Connect PDx pins to FMC Alternate function */
490  GPIOD->AFR[0] = 0x000000CC;
491  GPIOD->AFR[1] = 0xCC000CCC;
492  /* Configure PDx pins in Alternate function mode */
493  GPIOD->MODER = 0xA02A000A;
494  /* Configure PDx pins speed to 50 MHz */
495  GPIOD->OSPEEDR = 0xA02A000A;
496  /* Configure PDx pins Output type to push-pull */
497  GPIOD->OTYPER = 0x00000000;
498  /* No pull-up, pull-down for PDx pins */
499  GPIOD->PUPDR = 0x00000000;
500 
501  /* Connect PEx pins to FMC Alternate function */
502  GPIOE->AFR[0] = 0xC00000CC;
503  GPIOE->AFR[1] = 0xCCCCCCCC;
504  /* Configure PEx pins in Alternate function mode */
505  GPIOE->MODER = 0xAAAA800A;
506  /* Configure PEx pins speed to 50 MHz */
507  GPIOE->OSPEEDR = 0xAAAA800A;
508  /* Configure PEx pins Output type to push-pull */
509  GPIOE->OTYPER = 0x00000000;
510  /* No pull-up, pull-down for PEx pins */
511  GPIOE->PUPDR = 0x00000000;
512 
513  /* Connect PFx pins to FMC Alternate function */
514  GPIOF->AFR[0] = 0xCCCCCCCC;
515  GPIOF->AFR[1] = 0xCCCCCCCC;
516  /* Configure PFx pins in Alternate function mode */
517  GPIOF->MODER = 0xAA800AAA;
518  /* Configure PFx pins speed to 50 MHz */
519  GPIOF->OSPEEDR = 0xAA800AAA;
520  /* Configure PFx pins Output type to push-pull */
521  GPIOF->OTYPER = 0x00000000;
522  /* No pull-up, pull-down for PFx pins */
523  GPIOF->PUPDR = 0x00000000;
524 
525  /* Connect PGx pins to FMC Alternate function */
526  GPIOG->AFR[0] = 0xCCCCCCCC;
527  GPIOG->AFR[1] = 0xCCCCCCCC;
528  /* Configure PGx pins in Alternate function mode */
529  GPIOG->MODER = 0xAAAAAAAA;
530  /* Configure PGx pins speed to 50 MHz */
531  GPIOG->OSPEEDR = 0xAAAAAAAA;
532  /* Configure PGx pins Output type to push-pull */
533  GPIOG->OTYPER = 0x00000000;
534  /* No pull-up, pull-down for PGx pins */
535  GPIOG->PUPDR = 0x00000000;
536 
537 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
538  || defined(STM32F469xx) || defined(STM32F479xx)
539  /* Connect PHx pins to FMC Alternate function */
540  GPIOH->AFR[0] = 0x00C0CC00;
541  GPIOH->AFR[1] = 0xCCCCCCCC;
542  /* Configure PHx pins in Alternate function mode */
543  GPIOH->MODER = 0xAAAA08A0;
544  /* Configure PHx pins speed to 50 MHz */
545  GPIOH->OSPEEDR = 0xAAAA08A0;
546  /* Configure PHx pins Output type to push-pull */
547  GPIOH->OTYPER = 0x00000000;
548  /* No pull-up, pull-down for PHx pins */
549  GPIOH->PUPDR = 0x00000000;
550 
551  /* Connect PIx pins to FMC Alternate function */
552  GPIOI->AFR[0] = 0xCCCCCCCC;
553  GPIOI->AFR[1] = 0x00000CC0;
554  /* Configure PIx pins in Alternate function mode */
555  GPIOI->MODER = 0x0028AAAA;
556  /* Configure PIx pins speed to 50 MHz */
557  GPIOI->OSPEEDR = 0x0028AAAA;
558  /* Configure PIx pins Output type to push-pull */
559  GPIOI->OTYPER = 0x00000000;
560  /* No pull-up, pull-down for PIx pins */
561  GPIOI->PUPDR = 0x00000000;
562 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
563 
564 /*-- FMC Configuration -------------------------------------------------------*/
565  /* Enable the FMC interface clock */
566  RCC->AHB3ENR |= 0x00000001;
567  /* Delay after an RCC peripheral clock enabling */
568  tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
569 
570  /* Configure and enable SDRAM bank1 */
571 #if defined(STM32F446xx)
572  FMC_Bank5_6->SDCR[0] = 0x00001954;
573 #else
574  FMC_Bank5_6->SDCR[0] = 0x000019E4;
575 #endif /* STM32F446xx */
576  FMC_Bank5_6->SDTR[0] = 0x01115351;
577 
578  /* SDRAM initialization sequence */
579  /* Clock enable command */
580  FMC_Bank5_6->SDCMR = 0x00000011;
581  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
582  while((tmpreg != 0) && (timeout-- > 0))
583  {
584  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
585  }
586 
587  /* Delay */
588  for (index = 0; index<1000; index++);
589 
590  /* PALL command */
591  FMC_Bank5_6->SDCMR = 0x00000012;
592  timeout = 0xFFFF;
593  while((tmpreg != 0) && (timeout-- > 0))
594  {
595  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
596  }
597 
598  /* Auto refresh command */
599 #if defined(STM32F446xx)
600  FMC_Bank5_6->SDCMR = 0x000000F3;
601 #else
602  FMC_Bank5_6->SDCMR = 0x00000073;
603 #endif /* STM32F446xx */
604  timeout = 0xFFFF;
605  while((tmpreg != 0) && (timeout-- > 0))
606  {
607  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
608  }
609 
610  /* MRD register program */
611 #if defined(STM32F446xx)
612  FMC_Bank5_6->SDCMR = 0x00044014;
613 #else
614  FMC_Bank5_6->SDCMR = 0x00046014;
615 #endif /* STM32F446xx */
616  timeout = 0xFFFF;
617  while((tmpreg != 0) && (timeout-- > 0))
618  {
619  tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
620  }
621 
622  /* Set refresh count */
623  tmpreg = FMC_Bank5_6->SDRTR;
624 #if defined(STM32F446xx)
625  FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1));
626 #else
627  FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
628 #endif /* STM32F446xx */
629 
630  /* Disable write protection */
631  tmpreg = FMC_Bank5_6->SDCR[0];
632  FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
633 #endif /* DATA_IN_ExtSDRAM */
634 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
635 
636 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
637  || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
638  || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
639 
640 #if defined(DATA_IN_ExtSRAM)
641 /*-- GPIOs Configuration -----------------------------------------------------*/
642  /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
643  RCC->AHB1ENR |= 0x00000078;
644  /* Delay after an RCC peripheral clock enabling */
645  tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);
646 
647  /* Connect PDx pins to FMC Alternate function */
648  GPIOD->AFR[0] = 0x00CCC0CC;
649  GPIOD->AFR[1] = 0xCCCCCCCC;
650  /* Configure PDx pins in Alternate function mode */
651  GPIOD->MODER = 0xAAAA0A8A;
652  /* Configure PDx pins speed to 100 MHz */
653  GPIOD->OSPEEDR = 0xFFFF0FCF;
654  /* Configure PDx pins Output type to push-pull */
655  GPIOD->OTYPER = 0x00000000;
656  /* No pull-up, pull-down for PDx pins */
657  GPIOD->PUPDR = 0x00000000;
658 
659  /* Connect PEx pins to FMC Alternate function */
660  GPIOE->AFR[0] = 0xC00CC0CC;
661  GPIOE->AFR[1] = 0xCCCCCCCC;
662  /* Configure PEx pins in Alternate function mode */
663  GPIOE->MODER = 0xAAAA828A;
664  /* Configure PEx pins speed to 100 MHz */
665  GPIOE->OSPEEDR = 0xFFFFC3CF;
666  /* Configure PEx pins Output type to push-pull */
667  GPIOE->OTYPER = 0x00000000;
668  /* No pull-up, pull-down for PEx pins */
669  GPIOE->PUPDR = 0x00000000;
670 
671  /* Connect PFx pins to FMC Alternate function */
672  GPIOF->AFR[0] = 0x00CCCCCC;
673  GPIOF->AFR[1] = 0xCCCC0000;
674  /* Configure PFx pins in Alternate function mode */
675  GPIOF->MODER = 0xAA000AAA;
676  /* Configure PFx pins speed to 100 MHz */
677  GPIOF->OSPEEDR = 0xFF000FFF;
678  /* Configure PFx pins Output type to push-pull */
679  GPIOF->OTYPER = 0x00000000;
680  /* No pull-up, pull-down for PFx pins */
681  GPIOF->PUPDR = 0x00000000;
682 
683  /* Connect PGx pins to FMC Alternate function */
684  GPIOG->AFR[0] = 0x00CCCCCC;
685  GPIOG->AFR[1] = 0x000000C0;
686  /* Configure PGx pins in Alternate function mode */
687  GPIOG->MODER = 0x00085AAA;
688  /* Configure PGx pins speed to 100 MHz */
689  GPIOG->OSPEEDR = 0x000CAFFF;
690  /* Configure PGx pins Output type to push-pull */
691  GPIOG->OTYPER = 0x00000000;
692  /* No pull-up, pull-down for PGx pins */
693  GPIOG->PUPDR = 0x00000000;
694 
695 /*-- FMC/FSMC Configuration --------------------------------------------------*/
696  /* Enable the FMC/FSMC interface clock */
697  RCC->AHB3ENR |= 0x00000001;
698 
699 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
700  /* Delay after an RCC peripheral clock enabling */
701  tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
702  /* Configure and enable Bank1_SRAM2 */
703  FMC_Bank1->BTCR[2] = 0x00001011;
704  FMC_Bank1->BTCR[3] = 0x00000201;
705  FMC_Bank1E->BWTR[2] = 0x0fffffff;
706 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
707 #if defined(STM32F469xx) || defined(STM32F479xx)
708  /* Delay after an RCC peripheral clock enabling */
709  tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
710  /* Configure and enable Bank1_SRAM2 */
711  FMC_Bank1->BTCR[2] = 0x00001091;
712  FMC_Bank1->BTCR[3] = 0x00110212;
713  FMC_Bank1E->BWTR[2] = 0x0fffffff;
714 #endif /* STM32F469xx || STM32F479xx */
715 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\
716  || defined(STM32F412Zx) || defined(STM32F412Vx)
717  /* Delay after an RCC peripheral clock enabling */
718  tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);
719  /* Configure and enable Bank1_SRAM2 */
720  FSMC_Bank1->BTCR[2] = 0x00001011;
721  FSMC_Bank1->BTCR[3] = 0x00000201;
722  FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF;
723 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */
724 
725 #endif /* DATA_IN_ExtSRAM */
726 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
727  STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */
728  (void)(tmp);
729 }
730 #endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
731 
742 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
SCB
#define SCB
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:1778
FLASH_BASE
#define FLASH_BASE
Definition: stm32f407xx.h:907
__IO
#define __IO
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:237
SystemCoreClockUpdate
void SystemCoreClockUpdate(void)
Update SystemCoreClock variable according to Clock Register Values. The SystemCoreClock variable cont...
Definition: system_MIMXRT1052.c:138
FMC_Bank1
#define FMC_Bank1
Definition: stm32f469xx.h:1376
APBPrescTable
const uint8_t APBPrescTable[8]
Definition: stm32f411/stm32f411e-disco/Src/system_stm32f4xx.c:137
GPIOE
#define GPIOE
Definition: stm32f407xx.h:1107
FSMC_Bank1E
#define FSMC_Bank1E
Definition: stm32f407xx.h:1137
SRAM_BASE
#define SRAM_BASE
Definition: stm32f407xx.h:924
FMC_Bank1E
#define FMC_Bank1E
Definition: stm32f469xx.h:1377
FSMC_Bank1
#define FSMC_Bank1
Definition: stm32f407xx.h:1136
RCC_CFGR_HPRE
#define RCC_CFGR_HPRE
Definition: stm32f407xx.h:9557
SystemInit
void SystemInit(void)
Setup the microcontroller system Initialize the FPU setting, vector table location and External memor...
Definition: system_MIMXRT1052.c:75
RCC_PLLCFGR_PLLSRC
#define RCC_PLLCFGR_PLLSRC
Definition: stm32f407xx.h:9516
HSE_VALUE
#define HSE_VALUE
Definition: stm32f411/stm32f411e-disco/Src/system_stm32f4xx.c:67
RCC_AHB1ENR_GPIODEN
#define RCC_AHB1ENR_GPIODEN
Definition: stm32f407xx.h:9888
RCC_AHB1ENR_GPIOCEN
#define RCC_AHB1ENR_GPIOCEN
Definition: stm32f407xx.h:9885
RCC_PLLCFGR_PLLM
#define RCC_PLLCFGR_PLLM
Definition: stm32f407xx.h:9487
RCC_CFGR_SWS
#define RCC_CFGR_SWS
Definition: stm32f407xx.h:9546
GPIOA
#define GPIOA
Definition: stm32f407xx.h:1103
SystemCoreClock
uint32_t SystemCoreClock
System clock frequency (core clock)
Definition: stm32f411/stm32f411e-disco/Src/system_stm32f4xx.c:135
FMC_Bank5_6
#define FMC_Bank5_6
Definition: stm32f469xx.h:1379
GPIOH
#define GPIOH
Definition: stm32f407xx.h:1110
READ_BIT
#define READ_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:216
GPIOI
#define GPIOI
Definition: stm32f407xx.h:1111
RCC
#define RCC
Definition: stm32f407xx.h:1113
RCC_AHB3ENR_FMCEN
#define RCC_AHB3ENR_FMCEN
Definition: stm32f469xx.h:14082
VECT_TAB_OFFSET
#define VECT_TAB_OFFSET
Definition: stm32f411/stm32f411e-disco/Src/system_stm32f4xx.c:108
AHBPrescTable
const uint8_t AHBPrescTable[16]
Definition: stm32f411/stm32f411e-disco/Src/system_stm32f4xx.c:136
RCC_PLLCFGR_PLLN
#define RCC_PLLCFGR_PLLN
Definition: stm32f407xx.h:9497
GPIOG
#define GPIOG
Definition: stm32f407xx.h:1109
RCC_AHB3ENR_FSMCEN
#define RCC_AHB3ENR_FSMCEN
Definition: stm32f407xx.h:9961
GPIOD
#define GPIOD
Definition: stm32f407xx.h:1106
GPIOF
#define GPIOF
Definition: stm32f407xx.h:1108
RCC_PLLCFGR_PLLP
#define RCC_PLLCFGR_PLLP
Definition: stm32f407xx.h:9510
GPIOC
#define GPIOC
Definition: stm32f407xx.h:1105
HSI_VALUE
#define HSI_VALUE
Definition: stm32f411/stm32f411e-disco/Src/system_stm32f4xx.c:71


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:55