Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the FMC frequency source to HCLK #995

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions libraries/Portenta_SDRAM/src/ram_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,7 @@ static HAL_StatusTypeDef FMC_SDRAM_Clock_Config(void)
RCC_PeriphCLKInitTypeDef RCC_PeriphCLKInitStruct;

RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_FMC;
RCC_PeriphCLKInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_PLL2;
#ifdef ARDUINO_GIGA
/* 16MHz HSE */
/* PLL2_VCO Input = HSE_VALUE/PLL2_M = (16/4) = 4 Mhz */
/* PLL2_VCO Output = PLL2_VCO Input * PLL_N = 4*100 = 400 Mhz */
/* FMC Kernel Clock = PLL2_VCO Output/PLL_R = 400/2 = 200 Mhz */
RCC_PeriphCLKInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_2;
RCC_PeriphCLKInitStruct.PLL2.PLL2M = 4;
RCC_PeriphCLKInitStruct.PLL2.PLL2N = 100;
#else
/* 25MHz HSE */
/* PLL2_VCO Input = HSE_VALUE/PLL2_M = 25/5 = 5 Mhz */
/* PLL2_VCO Output = PLL2_VCO Input * PLL_N = 5*80 = 400 Mhz */
/* FMC Kernel Clock = PLL2_VCO Output/PLL_R = 400/2 = 200 Mhz */
RCC_PeriphCLKInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_2;
RCC_PeriphCLKInitStruct.PLL2.PLL2M = 5;
RCC_PeriphCLKInitStruct.PLL2.PLL2N = 80;
#endif
RCC_PeriphCLKInitStruct.PLL2.PLL2FRACN = 0;
RCC_PeriphCLKInitStruct.PLL2.PLL2P = 2;
RCC_PeriphCLKInitStruct.PLL2.PLL2Q = 2;
RCC_PeriphCLKInitStruct.PLL2.PLL2R = 2;
RCC_PeriphCLKInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE;
RCC_PeriphCLKInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_HCLK;
return HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
}

Expand Down
6 changes: 6 additions & 0 deletions libraries/Portenta_SDRAM/src/ram_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ bool sdram_init(void);
#define MICROPY_HW_SDRAM_TIMING_TRP (3)
#define MICROPY_HW_SDRAM_TIMING_TRCD (3)
#define MICROPY_HW_SDRAM_REFRESH_RATE (64) // ms

#ifdef ARDUINO_GIGA
#define MICROPY_HW_SDRAM_FREQUENCY (120000) // 100 MHz
#else
#define MICROPY_HW_SDRAM_FREQUENCY (100000) // 100 MHz
#endif

#define MICROPY_HW_SDRAM_REFRESH_CYCLES 4096

#define MICROPY_HW_SDRAM_BURST_LENGTH 1
Expand Down