mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 17:33:08 +08:00
boards/arm/stm32/stm32f769i-disco: Add support for external SDRAM
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
f5039d0b23
commit
b06722cd7f
+315
-280
File diff suppressed because it is too large
Load Diff
@@ -68,16 +68,16 @@
|
||||
#define STM32_FMC_NADDRCONFIGS 22
|
||||
#define STM32_FMC_NDATACONFIGS 16
|
||||
|
||||
#define STM32_SDRAM_CLKEN FMC_SDRAM_MODE_CMD_CLK_ENABLE | FMC_SDRAM_CMD_BANK_1
|
||||
#define STM32_SDRAM_PALL FMC_SDRAM_MODE_CMD_PALL | FMC_SDRAM_CMD_BANK_1
|
||||
#define STM32_SDRAM_REFRESH FMC_SDRAM_MODE_CMD_AUTO_REFRESH | FMC_SDRAM_CMD_BANK_1 |\
|
||||
(7 << FMC_SDRAM_AUTO_REFRESH_SHIFT)
|
||||
#define STM32_SDRAM_MODEREG FMC_SDRAM_MODE_CMD_LOAD_MODE | FMC_SDRAM_CMD_BANK_1 |\
|
||||
FMC_SDRAM_MODEREG_BURST_LENGTH_1 | \
|
||||
FMC_SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\
|
||||
FMC_SDRAM_MODEREG_CAS_LATENCY_3 |\
|
||||
FMC_SDRAM_MODEREG_WRITEBURST_MODE_SINGLE
|
||||
|
||||
#define STM32_SDRAM_CLKEN FMC_SDCMR_CTB1 | FMC_SDCMR_MODE_CLK_ENABLE
|
||||
#define STM32_SDRAM_PALL FMC_SDCMR_CTB1 | FMC_SDCMR_MODE_PALL
|
||||
#define STM32_SDRAM_REFRESH FMC_SDCMR_CTB1 | FMC_SDCMR_MODE_AUTO_REFRESH |\
|
||||
FMC_SDCMR_NRFS(8)
|
||||
#define STM32_SDRAM_MODEREG FMC_SDCMR_CTB1 | FMC_SDCMR_MODE_LOAD_MODE |\
|
||||
FMC_SDCMR_MRD_BURST_LENGTH_1 | \
|
||||
FMC_SDCMR_MRD_BURST_TYPE_SEQUENTIAL |\
|
||||
FMC_SDCMR_MRD_CAS_LATENCY_3 |\
|
||||
FMC_SDCMR_MRD_OPERATING_MODE_STANDARD |\
|
||||
FMC_SDCMR_MRD_WRITEBURST_MODE_SINGLE
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@@ -87,8 +87,9 @@
|
||||
|
||||
static const uint32_t g_addressconfig[STM32_FMC_NADDRCONFIGS] =
|
||||
{
|
||||
GPIO_FMC_A0, GPIO_FMC_A1, GPIO_FMC_A2, GPIO_FMC_A3, GPIO_FMC_A4 , GPIO_FMC_A5,
|
||||
GPIO_FMC_A6, GPIO_FMC_A7, GPIO_FMC_A8, GPIO_FMC_A9, GPIO_FMC_A10, GPIO_FMC_A11,
|
||||
GPIO_FMC_A0, GPIO_FMC_A1, GPIO_FMC_A2, GPIO_FMC_A3, GPIO_FMC_A4,
|
||||
GPIO_FMC_A5, GPIO_FMC_A6, GPIO_FMC_A7, GPIO_FMC_A8, GPIO_FMC_A9,
|
||||
GPIO_FMC_A10, GPIO_FMC_A11,
|
||||
|
||||
GPIO_FMC_SDCKE0_1, GPIO_FMC_SDNE0_3, GPIO_FMC_SDNWE_3, GPIO_FMC_NBL0,
|
||||
GPIO_FMC_SDNRAS, GPIO_FMC_NBL1, GPIO_FMC_BA0, GPIO_FMC_BA1,
|
||||
@@ -97,9 +98,10 @@ static const uint32_t g_addressconfig[STM32_FMC_NADDRCONFIGS] =
|
||||
|
||||
static const uint32_t g_dataconfig[STM32_FMC_NDATACONFIGS] =
|
||||
{
|
||||
GPIO_FMC_D0, GPIO_FMC_D1 , GPIO_FMC_D2, GPIO_FMC_D3, GPIO_FMC_D4 , GPIO_FMC_D5,
|
||||
GPIO_FMC_D6, GPIO_FMC_D7, GPIO_FMC_D8, GPIO_FMC_D9, GPIO_FMC_D10, GPIO_FMC_D11,
|
||||
GPIO_FMC_D12, GPIO_FMC_D13, GPIO_FMC_D14, GPIO_FMC_D15
|
||||
GPIO_FMC_D0, GPIO_FMC_D1, GPIO_FMC_D2, GPIO_FMC_D3, GPIO_FMC_D4,
|
||||
GPIO_FMC_D5, GPIO_FMC_D6, GPIO_FMC_D7, GPIO_FMC_D8, GPIO_FMC_D9,
|
||||
GPIO_FMC_D10, GPIO_FMC_D11, GPIO_FMC_D12, GPIO_FMC_D13, GPIO_FMC_D14,
|
||||
GPIO_FMC_D15
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -145,19 +147,20 @@ static void stm32_extmemgpios(const uint32_t *gpios, int ngpios)
|
||||
static void stm32_sdramcommand(uint32_t command)
|
||||
{
|
||||
uint32_t regval;
|
||||
volatile uint32_t timeout = 0xFFFF;
|
||||
volatile uint32_t timeout = 0xffff;
|
||||
|
||||
regval = getreg32( STM32_FMC_SDSR ) & 0x00000020;
|
||||
regval = getreg32(STM32_FMC_SDSR) & 0x00000020;
|
||||
while ((regval != 0) && timeout-- > 0)
|
||||
{
|
||||
regval = getreg32( STM32_FMC_SDSR ) & 0x00000020;
|
||||
regval = getreg32(STM32_FMC_SDSR) & 0x00000020;
|
||||
}
|
||||
|
||||
putreg32(command, STM32_FMC_SDCMR);
|
||||
timeout = 0xFFFF;
|
||||
regval = getreg32( STM32_FMC_SDSR ) & 0x00000020;
|
||||
timeout = 0xffff;
|
||||
regval = getreg32(STM32_FMC_SDSR) & 0x00000020;
|
||||
while ((regval != 0) && timeout-- > 0)
|
||||
{
|
||||
regval = getreg32( STM32_FMC_SDSR ) & 0x00000020;
|
||||
regval = getreg32(STM32_FMC_SDSR) & 0x00000020;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +184,7 @@ void stm32_enablefmc(void)
|
||||
|
||||
/* Enable AHB clocking to the FMC */
|
||||
|
||||
regval = getreg32( STM32_RCC_AHB3ENR);
|
||||
regval = getreg32(STM32_RCC_AHB3ENR);
|
||||
regval |= RCC_AHB3ENR_FMCEN;
|
||||
putreg32(regval, STM32_RCC_AHB3ENR);
|
||||
|
||||
@@ -192,29 +195,29 @@ void stm32_enablefmc(void)
|
||||
* All timings from the datasheet for Speedgrade -6A (=6ns)
|
||||
*/
|
||||
|
||||
putreg32(FMC_SDRAM_CR_RPIPE_0 |
|
||||
FMC_SDRAM_CR_BURST_READ |
|
||||
FMC_SDRAM_CR_SDCLK_2X |
|
||||
FMC_SDRAM_CR_CASLAT_3 |
|
||||
FMC_SDRAM_CR_BANKS_4 |
|
||||
FMC_SDRAM_CR_WIDTH_16 |
|
||||
FMC_SDRAM_CR_ROWBITS_12 |
|
||||
FMC_SDRAM_CR_COLBITS_8,
|
||||
putreg32(FMC_SDCR_RPIPE_0 |
|
||||
FMC_SDCR_BURST_READ |
|
||||
FMC_SDCR_SDCLK_2X |
|
||||
FMC_SDCR_CASLAT_3 |
|
||||
FMC_SDCR_BANKS_4 |
|
||||
FMC_SDCR_WIDTH_16 |
|
||||
FMC_SDCR_ROWBITS_12 |
|
||||
FMC_SDCR_COLBITS_8,
|
||||
STM32_FMC_SDCR1);
|
||||
|
||||
putreg32((1 << FMC_SDRAM_TR_TRCD_SHIFT) | /* tRCD min = 18ns */
|
||||
(1 << FMC_SDRAM_TR_TRP_SHIFT) | /* tRP min = 18ns */
|
||||
(1 << FMC_SDRAM_TR_TWR_SHIFT) | /* tWR = 2CLK */
|
||||
(6 << FMC_SDRAM_TR_TRC_SHIFT) | /* tRC min = 64ns */
|
||||
(4 << FMC_SDRAM_TR_TRAS_SHIFT) | /* tRAS min = 46ns */
|
||||
(7 << FMC_SDRAM_TR_TXSR_SHIFT) | /* tXSR min = 74ns */
|
||||
(1 << FMC_SDRAM_TR_TMRD_SHIFT), /* tMRD = 2CLK */
|
||||
putreg32(FMC_SDTR_TRCD(2) | /* tRCD min = 18ns */
|
||||
FMC_SDTR_TRP(2) | /* tRP min = 18ns */
|
||||
FMC_SDTR_TWR(2) | /* tWR = 2CLK */
|
||||
FMC_SDTR_TRC(7) | /* tRC min = 64ns */
|
||||
FMC_SDTR_TRAS(5) | /* tRAS min = 46ns */
|
||||
FMC_SDTR_TXSR(8) | /* tXSR min = 74ns */
|
||||
FMC_SDTR_TMRD(2), /* tMRD = 2CLK */
|
||||
STM32_FMC_SDTR1);
|
||||
|
||||
/* SDRAM Initialization sequence */
|
||||
|
||||
stm32_sdramcommand(STM32_SDRAM_CLKEN); /* Clock enable command */
|
||||
for (count = 0; count < 10000; count++) ; /* Delay */
|
||||
for (count = 0; count < 10000; count++) ; /* Delay */
|
||||
stm32_sdramcommand(STM32_SDRAM_PALL); /* Precharge ALL command */
|
||||
stm32_sdramcommand(STM32_SDRAM_REFRESH); /* Auto refresh command */
|
||||
stm32_sdramcommand(STM32_SDRAM_MODEREG); /* Mode Register program */
|
||||
|
||||
@@ -63,4 +63,8 @@ ifeq ($(CONFIG_SPORADIC_INSTRUMENTATION),y)
|
||||
CSRCS += stm32_sporadic.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STM32F7_FMC),y)
|
||||
CSRCS += stm32_extmem.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/boards/Board.mk
|
||||
|
||||
@@ -86,7 +86,7 @@ void stm32_boardinitialize(void)
|
||||
|
||||
#ifdef CONFIG_SPORADIC_INSTRUMENTATION
|
||||
/* This configuration has been used for evaluating the NuttX sporadic scheduler.
|
||||
* The following caqll initializes the sporadic scheduler monitor.
|
||||
* The following call initializes the sporadic scheduler monitor.
|
||||
*/
|
||||
|
||||
arch_sporadic_initialize();
|
||||
@@ -97,6 +97,10 @@ void stm32_boardinitialize(void)
|
||||
|
||||
board_autoled_initialize();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STM32F7_FMC
|
||||
stm32_sdram_initialize();
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32f7/stm32f769i-disco/src/stm32_extmem.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "arm_arch.h"
|
||||
|
||||
#include "stm32_fmc.h"
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32_rcc.h"
|
||||
#include "stm32f769i-disco.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_STM32F7_FMC
|
||||
# warning "FMC is not enabled"
|
||||
#endif
|
||||
|
||||
#if STM32F7_NGPIO < 8
|
||||
# error "Required GPIO ports not enabled"
|
||||
#endif
|
||||
|
||||
#define STM32_FMC_NADDRCONFIGS 25
|
||||
#define STM32_FMC_NDATACONFIGS 32
|
||||
|
||||
#define STM32_SDRAM_CLKEN FMC_SDCMR_CTB1 | FMC_SDCMR_MODE_CLK_ENABLE
|
||||
#define STM32_SDRAM_PALL FMC_SDCMR_CTB1 | FMC_SDCMR_MODE_PALL
|
||||
#define STM32_SDRAM_REFRESH FMC_SDCMR_CTB1 | FMC_SDCMR_MODE_AUTO_REFRESH |\
|
||||
FMC_SDCMR_NRFS(8)
|
||||
#define STM32_SDRAM_MODEREG FMC_SDCMR_CTB1 | FMC_SDCMR_MODE_LOAD_MODE |\
|
||||
FMC_SDCMR_MRD_BURST_LENGTH_1 | \
|
||||
FMC_SDCMR_MRD_BURST_TYPE_SEQUENTIAL |\
|
||||
FMC_SDCMR_MRD_CAS_LATENCY_3 |\
|
||||
FMC_SDCMR_MRD_OPERATING_MODE_STANDARD |\
|
||||
FMC_SDCMR_MRD_WRITEBURST_MODE_SINGLE
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* GPIO configurations common to most external memories */
|
||||
|
||||
static const uint32_t g_addressconfig[STM32_FMC_NADDRCONFIGS] =
|
||||
{
|
||||
GPIO_FMC_A0, GPIO_FMC_A1, GPIO_FMC_A2, GPIO_FMC_A3, GPIO_FMC_A4,
|
||||
GPIO_FMC_A5, GPIO_FMC_A6, GPIO_FMC_A7, GPIO_FMC_A8, GPIO_FMC_A9,
|
||||
GPIO_FMC_A10, GPIO_FMC_A11, GPIO_FMC_A12,
|
||||
|
||||
GPIO_FMC_NBL0, GPIO_FMC_NBL1, GPIO_FMC_NBL2, GPIO_FMC_NBL3, GPIO_FMC_BA0,
|
||||
GPIO_FMC_BA1, GPIO_FMC_SDNWE_3, GPIO_FMC_SDNCAS, GPIO_FMC_SDNRAS,
|
||||
GPIO_FMC_SDNE0_3, GPIO_FMC_SDCKE0_3, GPIO_FMC_SDCLK
|
||||
};
|
||||
|
||||
static const uint32_t g_dataconfig[STM32_FMC_NDATACONFIGS] =
|
||||
{
|
||||
GPIO_FMC_D0, GPIO_FMC_D1, GPIO_FMC_D2, GPIO_FMC_D3, GPIO_FMC_D4,
|
||||
GPIO_FMC_D5, GPIO_FMC_D6, GPIO_FMC_D7, GPIO_FMC_D8, GPIO_FMC_D9,
|
||||
GPIO_FMC_D10, GPIO_FMC_D11, GPIO_FMC_D12, GPIO_FMC_D13, GPIO_FMC_D14,
|
||||
GPIO_FMC_D15, GPIO_FMC_D16, GPIO_FMC_D17, GPIO_FMC_D18, GPIO_FMC_D19,
|
||||
GPIO_FMC_D20, GPIO_FMC_D21, GPIO_FMC_D22, GPIO_FMC_D23, GPIO_FMC_D24,
|
||||
GPIO_FMC_D25, GPIO_FMC_D26, GPIO_FMC_D27, GPIO_FMC_D28, GPIO_FMC_D29,
|
||||
GPIO_FMC_D30, GPIO_FMC_D31
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_fmc_sdram_wait
|
||||
*
|
||||
* Description:
|
||||
* Wait for the SDRAM controller to be ready.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void stm32_fmc_sdram_wait(void)
|
||||
{
|
||||
int timeout = 0xffff;
|
||||
while (timeout > 0)
|
||||
{
|
||||
if ((getreg32(STM32_FMC_SDSR) & FMC_SDSR_BUSY) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
timeout--;
|
||||
}
|
||||
|
||||
DEBUGASSERT(timeout > 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_fmc_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable clocking to the FMC.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void stm32_fmc_enable(void)
|
||||
{
|
||||
modifyreg32(STM32_RCC_AHB3ENR, 0, RCC_AHB3ENR_FMCEN);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_fmc_sdram_set_refresh_rate
|
||||
*
|
||||
* Description:
|
||||
* Set the SDRAM refresh rate.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void stm32_fmc_sdram_set_refresh_rate(int count)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
DEBUGASSERT(count <= 0x1fff && count >= 0x29);
|
||||
|
||||
stm32_fmc_sdram_wait();
|
||||
|
||||
val = getreg32(STM32_FMC_SDRTR);
|
||||
val &= ~(0x1fff << 1); /* preserve non-count bits */
|
||||
val |= (count << 1);
|
||||
putreg32(val, STM32_FMC_SDRTR);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_fmc_sdram_set_timing
|
||||
*
|
||||
* Description:
|
||||
* Set the SDRAM timing parameters.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void stm32_fmc_sdram_set_timing(int bank, uint32_t timing)
|
||||
{
|
||||
uint32_t val;
|
||||
uint32_t sdtr;
|
||||
|
||||
DEBUGASSERT((bank == 1) || (bank == 2));
|
||||
DEBUGASSERT((timing & FMC_SDTR_RESERVED) == 0);
|
||||
|
||||
sdtr = (bank == 1) ? STM32_FMC_SDTR1 : STM32_FMC_SDTR2;
|
||||
val = getreg32(sdtr);
|
||||
val &= FMC_SDTR_RESERVED; /* preserve reserved bits */
|
||||
val |= timing;
|
||||
putreg32(val, sdtr);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_fmc_sdram_set_control
|
||||
*
|
||||
* Description:
|
||||
* Set the SDRAM control parameters.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void stm32_fmc_sdram_set_control(int bank, uint32_t ctrl)
|
||||
{
|
||||
uint32_t val;
|
||||
uint32_t sdcr;
|
||||
|
||||
DEBUGASSERT((bank == 1) || (bank == 2));
|
||||
DEBUGASSERT((ctrl & FMC_SDCR_RESERVED) == 0);
|
||||
|
||||
sdcr = (bank == 1) ? STM32_FMC_SDCR1 : STM32_FMC_SDCR2;
|
||||
val = getreg32(sdcr);
|
||||
val &= FMC_SDCR_RESERVED; /* preserve reserved bits */
|
||||
val |= ctrl;
|
||||
putreg32(val, sdcr);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_fmc_sdram_command
|
||||
*
|
||||
* Description:
|
||||
* Send a command to the SDRAM.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void stm32_fmc_sdram_command(uint32_t cmd)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
DEBUGASSERT((cmd & FMC_SDCMR_RESERVED) == 0);
|
||||
|
||||
/* Wait for the controller to be ready */
|
||||
|
||||
stm32_fmc_sdram_wait();
|
||||
|
||||
val = getreg32(STM32_FMC_SDCMR);
|
||||
val &= FMC_SDCMR_RESERVED; /* Preserve reserved bits */
|
||||
val |= cmd;
|
||||
putreg32(val, STM32_FMC_SDCMR);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_extmemgpios
|
||||
*
|
||||
* Description:
|
||||
* Initialize GPIOs for external memory usage.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void stm32_extmemgpios(const uint32_t *gpios, int ngpios)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Configure GPIOs */
|
||||
|
||||
for (i = 0; i < ngpios; i++)
|
||||
{
|
||||
stm32_configgpio(gpios[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_sdram_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called from stm32_bringup to initialize external SDRAM access.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void stm32_sdram_initialize(void)
|
||||
{
|
||||
uint32_t val;
|
||||
volatile int count;
|
||||
|
||||
/* Enable GPIOs as FMC / memory pins */
|
||||
|
||||
stm32_extmemgpios(g_addressconfig, STM32_FMC_NADDRCONFIGS);
|
||||
stm32_extmemgpios(g_dataconfig, STM32_FMC_NDATACONFIGS);
|
||||
|
||||
/* Enable AHB clocking to the FMC */
|
||||
|
||||
stm32_fmc_enable();
|
||||
|
||||
/* Configure and enable the SDRAM bank1
|
||||
*
|
||||
* FMC clock = 216MHz/2 = 108MHz
|
||||
* 108MHz = 9,26 ns
|
||||
* All timings from the datasheet for Speedgrade -6A (=6ns)
|
||||
*/
|
||||
|
||||
val = FMC_SDCR_RPIPE_0 | /* rpipe = 0 hclk */
|
||||
FMC_SDCR_BURST_READ | /* enable burst read */
|
||||
FMC_SDCR_SDCLK_2X | /* sdclk = 2 hclk */
|
||||
FMC_SDCR_CASLAT_3 | /* cas latency = 3 cycles */
|
||||
FMC_SDCR_BANKS_4 | /* 4 internal banks */
|
||||
FMC_SDCR_WIDTH_32 | /* width = 32 bits */
|
||||
FMC_SDCR_ROWBITS_12 | /* numrows = 12 bits */
|
||||
FMC_SDCR_COLBITS_8; /* numcols = 8 bits */
|
||||
stm32_fmc_sdram_set_control(1, val);
|
||||
|
||||
val = FMC_SDTR_TRCD(2) | /* tRCD min = 18ns */
|
||||
FMC_SDTR_TRP(2) | /* tRP min = 18ns */
|
||||
FMC_SDTR_TWR(3) | /* tWR = 3CLK */
|
||||
FMC_SDTR_TRC(7) | /* tRC min = 64ns */
|
||||
FMC_SDTR_TRAS(4) | /* tRAS min = 37ns */
|
||||
FMC_SDTR_TXSR(7) | /* tXSR min = 64ns */
|
||||
FMC_SDTR_TMRD(2); /* tMRD = 2CLK */
|
||||
stm32_fmc_sdram_set_timing(1, val);
|
||||
|
||||
/* SDRAM Initialization sequence */
|
||||
|
||||
stm32_fmc_sdram_command(STM32_SDRAM_CLKEN); /* Clock enable command */
|
||||
|
||||
for (count = 0; count < 10000; count++); /* Delay */
|
||||
|
||||
stm32_fmc_sdram_command(STM32_SDRAM_PALL); /* Precharge ALL command */
|
||||
stm32_fmc_sdram_command(STM32_SDRAM_REFRESH); /* Auto refresh command */
|
||||
stm32_fmc_sdram_command(STM32_SDRAM_MODEREG); /* Mode Register program */
|
||||
|
||||
/* Set refresh count
|
||||
*
|
||||
* FMC_CLK = 108MHz
|
||||
* Refresh_Rate = 64ms / 4096 rows = 15.63us
|
||||
* Counter = (FMC_CLK * Refresh_Rate) - 20
|
||||
*/
|
||||
|
||||
stm32_fmc_sdram_set_refresh_rate(1668);
|
||||
}
|
||||
@@ -74,9 +74,11 @@
|
||||
|
||||
#define GPIO_BTN_USER (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | GPIO_PORTA | GPIO_PIN0)
|
||||
|
||||
/* Sporadic scheduler instrumentation. This configuration has been used for evaluating the NuttX
|
||||
* sporadic scheduler. In this evaluation, two GPIO outputs are used. One indicating the priority
|
||||
* (high or low) of the sporadic thread and one indicating where the thread is running or not.
|
||||
/* Sporadic scheduler instrumentation.
|
||||
* This configuration has been used for evaluating the NuttX sporadic scheduler.
|
||||
* In this evaluation, two GPIO outputs are used. One indicating the priority
|
||||
* (high or low) of the sporadic thread and one indicating where the thread is
|
||||
* running or not.
|
||||
*
|
||||
* There is nothing special about the pin selections:
|
||||
*
|
||||
@@ -157,5 +159,17 @@ void weak_function stm32_spidev_initialize(void);
|
||||
void arch_sporadic_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_sdram_initialize
|
||||
*
|
||||
* Description:
|
||||
* Called from stm32_bringup to initialize external SDRAM access.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_STM32F7_FMC
|
||||
void stm32_sdram_initialize(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_ARM_STM32F7_STM32F769I_DISCO_SRC_STM32F769I_DISCO_H */
|
||||
|
||||
Reference in New Issue
Block a user