summaryrefslogtreecommitdiff
path: root/ports/stm32/sdram.c
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2024-11-30 09:56:23 +0100
committerDamien George <damien@micropython.org>2024-12-10 10:49:50 +1100
commit17808e7b749b269b58dcee67df599a0c61d455bd (patch)
treee41c7a3afc7e45a802617119e3fd4c08725b9a19 /ports/stm32/sdram.c
parent47d9988df2c7c6a4603f631b02a3f3a5c7e997f4 (diff)
stm32/sdram: Make SDRAM refresh count configurable by a board.
Refresh count calculations were using a hard-coded SDRAM frequency and refresh cycles, so change them to values that can be set by a board. And set these options to their existing values on STM32F769DISC and STM32F7DISC boards. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Diffstat (limited to 'ports/stm32/sdram.c')
-rw-r--r--ports/stm32/sdram.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ports/stm32/sdram.c b/ports/stm32/sdram.c
index e99f34d22..7104eb68e 100644
--- a/ports/stm32/sdram.c
+++ b/ports/stm32/sdram.c
@@ -245,15 +245,15 @@ static void sdram_init_seq(SDRAM_HandleTypeDef
/* Send the command */
HAL_SDRAM_SendCommand(hsdram, command, 0x1000);
- /* Step 8: Set the refresh rate counter
+ /* Step 8: Set the refresh rate counter.
+ Assuming 90MHz frequency, 8192 refresh cycles and 64ms refresh rate:
RefreshRate = 64 ms / 8192 cyc = 7.8125 us/cyc
-
RefreshCycles = 7.8125 us * 90 MHz = 703
According to the formula on p.1665 of the reference manual,
we also need to subtract 20 from the value, so the target
refresh rate is 703 - 20 = 683.
*/
- #define REFRESH_COUNT (MICROPY_HW_SDRAM_REFRESH_RATE * 90000 / 8192 - 20)
+ #define REFRESH_COUNT (MICROPY_HW_SDRAM_REFRESH_RATE * MICROPY_HW_SDRAM_FREQUENCY_KHZ / MICROPY_HW_SDRAM_REFRESH_CYCLES - 20)
HAL_SDRAM_ProgramRefreshRate(hsdram, REFRESH_COUNT);
#if defined(STM32F7) || defined(STM32H7)