Skip to content

Commit 1f15f3c

Browse files
authored
Change the FMC frequency source to HCLK
Change the FMC frequency source to HCLK, freeing up PLL2 for other uses. On Portenta, the frequency will be same. On giga it will be higher but still within spec, and I timings should get recalculated based on MICROPY_HW_SDRAM_FREQUENCY.
1 parent 06d7756 commit 1f15f3c

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

libraries/Portenta_SDRAM/src/ram_internal.c

+1-22
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,7 @@ static HAL_StatusTypeDef FMC_SDRAM_Clock_Config(void)
3838
RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct;
3939

4040
RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_FMC;
41-
RCC_PeriphCLKInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_PLL2;
42-
#ifdef ARDUINO_GIGA
43-
/* 16MHz HSE */
44-
/* PLL2_VCO Input = HSE_VALUE/PLL2_M = (16/4) = 4 Mhz */
45-
/* PLL2_VCO Output = PLL2_VCO Input * PLL_N = 4*100 = 400 Mhz */
46-
/* FMC Kernel Clock = PLL2_VCO Output/PLL_R = 400/2 = 200 Mhz */
47-
RCC_PeriphCLKInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_2;
48-
RCC_PeriphCLKInitStruct.PLL2.PLL2M = 4;
49-
RCC_PeriphCLKInitStruct.PLL2.PLL2N = 100;
50-
#else
51-
/* 25MHz HSE */
52-
/* PLL2_VCO Input = HSE_VALUE/PLL2_M = 25/5 = 5 Mhz */
53-
/* PLL2_VCO Output = PLL2_VCO Input * PLL_N = 5*80 = 400 Mhz */
54-
/* FMC Kernel Clock = PLL2_VCO Output/PLL_R = 400/2 = 200 Mhz */
55-
RCC_PeriphCLKInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_2;
56-
RCC_PeriphCLKInitStruct.PLL2.PLL2M = 5;
57-
RCC_PeriphCLKInitStruct.PLL2.PLL2N = 80;
58-
#endif
59-
RCC_PeriphCLKInitStruct.PLL2.PLL2FRACN = 0;
60-
RCC_PeriphCLKInitStruct.PLL2.PLL2P = 2;
61-
RCC_PeriphCLKInitStruct.PLL2.PLL2Q = 2;
62-
RCC_PeriphCLKInitStruct.PLL2.PLL2R = 2;
41+
RCC_PeriphCLKInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_HCLK;
6342
RCC_PeriphCLKInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE;
6443
return HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
6544
}

libraries/Portenta_SDRAM/src/ram_internal.h

+6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ bool sdram_init(void);
1414
#define MICROPY_HW_SDRAM_TIMING_TRP (3)
1515
#define MICROPY_HW_SDRAM_TIMING_TRCD (3)
1616
#define MICROPY_HW_SDRAM_REFRESH_RATE (64) // ms
17+
18+
#ifdef ARDUINO_GIGA
19+
#define MICROPY_HW_SDRAM_FREQUENCY (120000) // 100 MHz
20+
#else
1721
#define MICROPY_HW_SDRAM_FREQUENCY (100000) // 100 MHz
22+
#endif
23+
1824
#define MICROPY_HW_SDRAM_REFRESH_CYCLES 4096
1925

2026
#define MICROPY_HW_SDRAM_BURST_LENGTH 1

0 commit comments

Comments
 (0)