84
84
HAL_StatusTypeDef HAL_Init (void );
85
85
86
86
#if !defined (HSE_VALUE )
87
- #define HSE_VALUE ((uint32_t)25000000 ) /*!< Default value of the External oscillator in Hz */
87
+ #define HSE_VALUE ((uint32_t)8000000 ) /*!< Default value of the External oscillator in Hz */
88
88
#endif /* HSE_VALUE */
89
89
90
90
#if !defined (HSI_VALUE )
@@ -108,15 +108,6 @@ HAL_StatusTypeDef HAL_Init(void);
108
108
*/
109
109
110
110
/************************* Miscellaneous Configuration ************************/
111
- /*!< Uncomment the following line if you need to use external SRAM or SDRAM mounted
112
- on EVAL board as data memory */
113
- /* #define DATA_IN_ExtSRAM */
114
- /* #define DATA_IN_ExtSDRAM */
115
-
116
- #if defined(DATA_IN_ExtSRAM ) && defined(DATA_IN_ExtSDRAM )
117
- #error "Please select DATA_IN_ExtSRAM or DATA_IN_ExtSDRAM "
118
- #endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
119
-
120
111
/*!< Uncomment the following line if you need to relocate your vector Table in
121
112
Internal SRAM. */
122
113
/* #define VECT_TAB_SRAM */
@@ -133,7 +124,7 @@ HAL_StatusTypeDef HAL_Init(void);
133
124
*/
134
125
135
126
/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
136
- #define USE_PLL_HSE_EXTC (1) /* Use external clock --> NOT USED ON THIS BOARD */
127
+ #define USE_PLL_HSE_EXTC (1) /* Use external clock */
137
128
#define USE_PLL_HSE_XTAL (1) /* Use external xtal */
138
129
139
130
/**
@@ -162,10 +153,6 @@ const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8,
162
153
/** @addtogroup STM32F7xx_System_Private_FunctionPrototypes
163
154
* @{
164
155
*/
165
- #if defined (DATA_IN_ExtSRAM ) || defined (DATA_IN_ExtSDRAM )
166
- static void SystemInit_ExtMemCtl (void );
167
- #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
168
-
169
156
#if (USE_PLL_HSE_XTAL != 0 ) || (USE_PLL_HSE_EXTC != 0 )
170
157
uint8_t SetSysClock_PLL_HSE (uint8_t bypass );
171
158
#endif
@@ -212,10 +199,6 @@ void SystemInit(void)
212
199
/* Disable all interrupts */
213
200
RCC -> CIR = 0x00000000 ;
214
201
215
- #if defined (DATA_IN_ExtSRAM ) || defined (DATA_IN_ExtSDRAM )
216
- SystemInit_ExtMemCtl ();
217
- #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
218
-
219
202
/* Configure the Vector Table location add offset address ------------------*/
220
203
#ifdef VECT_TAB_SRAM
221
204
SCB -> VTOR = SRAM1_BASE | VECT_TAB_OFFSET ; /* Vector Table Relocation in Internal SRAM */
@@ -324,231 +307,6 @@ void SystemCoreClockUpdate(void)
324
307
SystemCoreClock >>= tmp ;
325
308
}
326
309
327
- #if defined (DATA_IN_ExtSRAM ) || defined (DATA_IN_ExtSDRAM )
328
- /**
329
- * @brief Setup the external memory controller.
330
- * Called in startup_stm32f7xx.s before jump to main.
331
- * This function configures the external memories (SRAM/SDRAM)
332
- * This SRAM/SDRAM will be used as program data memory (including heap and stack).
333
- * @param None
334
- * @retval None
335
- */
336
- void SystemInit_ExtMemCtl (void )
337
- {
338
- __IO uint32_t tmp = 0 ;
339
- #if defined (DATA_IN_ExtSDRAM )
340
- register uint32_t tmpreg = 0 , timeout = 0xFFFF ;
341
- register uint32_t index ;
342
-
343
- /* Enable GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
344
- clock */
345
- RCC -> AHB1ENR |= 0x000001F8 ;
346
-
347
- /* Delay after an RCC peripheral clock enabling */
348
- tmp = READ_BIT (RCC -> AHB1ENR , RCC_AHB1ENR_GPIOEEN );
349
-
350
- /* Connect PDx pins to FMC Alternate function */
351
- GPIOD -> AFR [0 ] = 0x000000CC ;
352
- GPIOD -> AFR [1 ] = 0xCC000CCC ;
353
- /* Configure PDx pins in Alternate function mode */
354
- GPIOD -> MODER = 0xA02A000A ;
355
- /* Configure PDx pins speed to 50 MHz */
356
- GPIOD -> OSPEEDR = 0xA02A000A ;
357
- /* Configure PDx pins Output type to push-pull */
358
- GPIOD -> OTYPER = 0x00000000 ;
359
- /* No pull-up, pull-down for PDx pins */
360
- GPIOD -> PUPDR = 0x50150005 ;
361
-
362
- /* Connect PEx pins to FMC Alternate function */
363
- GPIOE -> AFR [0 ] = 0xC00000CC ;
364
- GPIOE -> AFR [1 ] = 0xCCCCCCCC ;
365
- /* Configure PEx pins in Alternate function mode */
366
- GPIOE -> MODER = 0xAAAA800A ;
367
- /* Configure PEx pins speed to 50 MHz */
368
- GPIOE -> OSPEEDR = 0xAAAA800A ;
369
- /* Configure PEx pins Output type to push-pull */
370
- GPIOE -> OTYPER = 0x00000000 ;
371
- /* No pull-up, pull-down for PEx pins */
372
- GPIOE -> PUPDR = 0x55554005 ;
373
-
374
- /* Connect PFx pins to FMC Alternate function */
375
- GPIOF -> AFR [0 ] = 0x00CCCCCC ;
376
- GPIOF -> AFR [1 ] = 0xCCCCC000 ;
377
- /* Configure PFx pins in Alternate function mode */
378
- GPIOF -> MODER = 0xAA800AAA ;
379
- /* Configure PFx pins speed to 50 MHz */
380
- GPIOF -> OSPEEDR = 0xAA800AAA ;
381
- /* Configure PFx pins Output type to push-pull */
382
- GPIOF -> OTYPER = 0x00000000 ;
383
- /* No pull-up, pull-down for PFx pins */
384
- GPIOF -> PUPDR = 0x55400555 ;
385
-
386
- /* Connect PGx pins to FMC Alternate function */
387
- GPIOG -> AFR [0 ] = 0x00CC00CC ;
388
- GPIOG -> AFR [1 ] = 0xC000000C ;
389
- /* Configure PGx pins in Alternate function mode */
390
- GPIOG -> MODER = 0x80020A0A ;
391
- /* Configure PGx pins speed to 50 MHz */
392
- GPIOG -> OSPEEDR = 0x80020A0A ;
393
- /* Configure PGx pins Output type to push-pull */
394
- GPIOG -> OTYPER = 0x00000000 ;
395
- /* No pull-up, pull-down for PGx pins */
396
- GPIOG -> PUPDR = 0x40010505 ;
397
-
398
- /* Connect PHx pins to FMC Alternate function */
399
- GPIOH -> AFR [0 ] = 0x00C0CC00 ;
400
- GPIOH -> AFR [1 ] = 0xCCCCCCCC ;
401
- /* Configure PHx pins in Alternate function mode */
402
- GPIOH -> MODER = 0xAAAA08A0 ;
403
- /* Configure PHx pins speed to 50 MHz */
404
- GPIOH -> OSPEEDR = 0xAAAA08A0 ;
405
- /* Configure PHx pins Output type to push-pull */
406
- GPIOH -> OTYPER = 0x00000000 ;
407
- /* No pull-up, pull-down for PHx pins */
408
- GPIOH -> PUPDR = 0x55550450 ;
409
-
410
- /* Connect PIx pins to FMC Alternate function */
411
- GPIOI -> AFR [0 ] = 0xCCCCCCCC ;
412
- GPIOI -> AFR [1 ] = 0x00000CC0 ;
413
- /* Configure PIx pins in Alternate function mode */
414
- GPIOI -> MODER = 0x0028AAAA ;
415
- /* Configure PIx pins speed to 50 MHz */
416
- GPIOI -> OSPEEDR = 0x0028AAAA ;
417
- /* Configure PIx pins Output type to push-pull */
418
- GPIOI -> OTYPER = 0x00000000 ;
419
- /* No pull-up, pull-down for PIx pins */
420
- GPIOI -> PUPDR = 0x00145555 ;
421
-
422
- /*-- FMC Configuration ------------------------------------------------------*/
423
- /* Enable the FMC interface clock */
424
- RCC -> AHB3ENR |= 0x00000001 ;
425
-
426
- /* Delay after an RCC peripheral clock enabling */
427
- tmp = READ_BIT (RCC -> AHB3ENR , RCC_AHB3ENR_FMCEN );
428
-
429
- /* Configure and enable SDRAM bank1 */
430
- FMC_Bank5_6 -> SDCR [0 ] = 0x000019E5 ;
431
- FMC_Bank5_6 -> SDTR [0 ] = 0x01116361 ;
432
-
433
- /* SDRAM initialization sequence */
434
- /* Clock enable command */
435
- FMC_Bank5_6 -> SDCMR = 0x00000011 ;
436
- tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
437
- while ((tmpreg != 0 ) && (timeout -- > 0 ))
438
- {
439
- tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
440
- }
441
-
442
- /* Delay */
443
- for (index = 0 ; index < 1000 ; index ++ );
444
-
445
- /* PALL command */
446
- FMC_Bank5_6 -> SDCMR = 0x00000012 ;
447
- timeout = 0xFFFF ;
448
- while ((tmpreg != 0 ) && (timeout -- > 0 ))
449
- {
450
- tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
451
- }
452
-
453
- /* Auto refresh command */
454
- FMC_Bank5_6 -> SDCMR = 0x000000F3 ;
455
- timeout = 0xFFFF ;
456
- while ((tmpreg != 0 ) && (timeout -- > 0 ))
457
- {
458
- tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
459
- }
460
-
461
- /* MRD register program */
462
- FMC_Bank5_6 -> SDCMR = 0x00046014 ;
463
- timeout = 0xFFFF ;
464
- while ((tmpreg != 0 ) && (timeout -- > 0 ))
465
- {
466
- tmpreg = FMC_Bank5_6 -> SDSR & 0x00000020 ;
467
- }
468
-
469
- /* Set refresh count */
470
- tmpreg = FMC_Bank5_6 -> SDRTR ;
471
- FMC_Bank5_6 -> SDRTR = (tmpreg | (0x00000603 <<1 ));
472
-
473
- /* Disable write protection */
474
- tmpreg = FMC_Bank5_6 -> SDCR [0 ];
475
- FMC_Bank5_6 -> SDCR [0 ] = (tmpreg & 0xFFFFFDFF );
476
- #endif /* DATA_IN_ExtSDRAM */
477
-
478
- #if defined(DATA_IN_ExtSRAM )
479
- /*-- GPIOs Configuration -----------------------------------------------------*/
480
- /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
481
- RCC -> AHB1ENR |= 0x00000078 ;
482
-
483
- /* Delay after an RCC peripheral clock enabling */
484
- tmp = READ_BIT (RCC -> AHB1ENR , RCC_AHB1ENR_GPIOEEN );
485
-
486
- /* Connect PDx pins to FMC Alternate function */
487
- GPIOD -> AFR [0 ] = 0x00CCC0CC ;
488
- GPIOD -> AFR [1 ] = 0xCCCCCCCC ;
489
- /* Configure PDx pins in Alternate function mode */
490
- GPIOD -> MODER = 0xAAAA0A8A ;
491
- /* Configure PDx pins speed to 100 MHz */
492
- GPIOD -> OSPEEDR = 0xFFFF0FCF ;
493
- /* Configure PDx pins Output type to push-pull */
494
- GPIOD -> OTYPER = 0x00000000 ;
495
- /* No pull-up, pull-down for PDx pins */
496
- GPIOD -> PUPDR = 0x55550545 ;
497
-
498
- /* Connect PEx pins to FMC Alternate function */
499
- GPIOE -> AFR [0 ] = 0xC00CC0CC ;
500
- GPIOE -> AFR [1 ] = 0xCCCCCCCC ;
501
- /* Configure PEx pins in Alternate function mode */
502
- GPIOE -> MODER = 0xAAAA828A ;
503
- /* Configure PEx pins speed to 100 MHz */
504
- GPIOE -> OSPEEDR = 0xFFFFC3CF ;
505
- /* Configure PEx pins Output type to push-pull */
506
- GPIOE -> OTYPER = 0x00000000 ;
507
- /* No pull-up, pull-down for PEx pins */
508
- GPIOE -> PUPDR = 0x55554145 ;
509
-
510
- /* Connect PFx pins to FMC Alternate function */
511
- GPIOF -> AFR [0 ] = 0x00CCCCCC ;
512
- GPIOF -> AFR [1 ] = 0xCCCC0000 ;
513
- /* Configure PFx pins in Alternate function mode */
514
- GPIOF -> MODER = 0xAA000AAA ;
515
- /* Configure PFx pins speed to 100 MHz */
516
- GPIOF -> OSPEEDR = 0xFF000FFF ;
517
- /* Configure PFx pins Output type to push-pull */
518
- GPIOF -> OTYPER = 0x00000000 ;
519
- /* No pull-up, pull-down for PFx pins */
520
- GPIOF -> PUPDR = 0x55000555 ;
521
-
522
- /* Connect PGx pins to FMC Alternate function */
523
- GPIOG -> AFR [0 ] = 0x00CCCCCC ;
524
- GPIOG -> AFR [1 ] = 0x000000C0 ;
525
- /* Configure PGx pins in Alternate function mode */
526
- GPIOG -> MODER = 0x00200AAA ;
527
- /* Configure PGx pins speed to 100 MHz */
528
- GPIOG -> OSPEEDR = 0x00300FFF ;
529
- /* Configure PGx pins Output type to push-pull */
530
- GPIOG -> OTYPER = 0x00000000 ;
531
- /* No pull-up, pull-down for PGx pins */
532
- GPIOG -> PUPDR = 0x00100555 ;
533
-
534
- /*-- FMC/FSMC Configuration --------------------------------------------------*/
535
- /* Enable the FMC/FSMC interface clock */
536
- RCC -> AHB3ENR |= 0x00000001 ;
537
-
538
- /* Delay after an RCC peripheral clock enabling */
539
- tmp = READ_BIT (RCC -> AHB3ENR , RCC_AHB3ENR_FMCEN );
540
-
541
- /* Configure and enable Bank1_SRAM2 */
542
- FMC_Bank1 -> BTCR [4 ] = 0x00001091 ;
543
- FMC_Bank1 -> BTCR [5 ] = 0x00110212 ;
544
- FMC_Bank1E -> BWTR [4 ] = 0x0FFFFFFF ;
545
-
546
- #endif /* DATA_IN_ExtSRAM */
547
-
548
- (void )(tmp );
549
- }
550
- #endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
551
-
552
310
/**
553
311
* @brief Configures the System clock source, PLL Multiplier and Divider factors,
554
312
* AHB/APBx prescalers and Flash settings
@@ -581,7 +339,7 @@ void SetSysClock(void)
581
339
}
582
340
583
341
// Output clock on MCO2 pin(PC9) for debugging purpose
584
- // Can be visualized on uSD card CN3 connector pin 8
342
+ // Can be visualized on CN8 connector pin 4
585
343
//HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4); // 216 MHz / 4 = 54 MHz
586
344
}
587
345
0 commit comments