本代码用型号为“IS42S16400J”的 SDRAM 芯片为 STM32 扩展内存。
它的行地址宽度为 12 位,列地址宽度为 8 位,内部含有 4 个 Bank,数据线宽度为 16 位,容量大小为8MB。
SDRAM 硬件连接图:
SDRAM 与 STM32 相连的引脚非常多,主要是地址线和数据线。
bsp_sdram.h
/**
******************************************************************************
* @file bsp_sdram.c
* @author Waao
* @version V1.0.0
* @date 24-Feb-2019
* @brief This file contains some board support package's functions for the configuration of the SysTick.
*
******************************************************************************
* @attention
*
* None
*
******************************************************************************
*/
#ifndef __BSP_SDRAM_H_
#define __BSP_SDRAM_H_
#include #include #include #include #define IS42S16400J_SIZE 0x800000 #define SDRAM_DEBUG_ON 1 #define SDRAM_INFO(fmt, arg...) printf("<<- SDRAM-INFO ->> "fmt"n", ##arg) #define SDRAM_ERROR(fmt, arg...) printf("<<- SDRAM-ERROR ->> "fmt"n", ##arg) #define SDRAM_DEBUG(fmt, arg...) do{ if(SDRAM_DEBUG_ON) printf("<<- SDRAM-DEBUG ->> [%d]"fmt"n", __LINE__, ##arg); } while(0) /* Bank selection */ #define FMC_BANK_SDRAM FMC_Bank2_SDRAM #define FMC_COMMAND_TARGET_BANK FMC_Command_Target_bank2 /* Data BaseAddress */ #define SDRAM_BANK_ADDR ((uint32_t)0xD0000000) /* Data width */ #define SDRAM_MEMORY_WIDTH FMC_SDMemory_Width_16b /* SDRAM CAS Latency */ #define SDRAM_CAS_LATENCY FMC_CAS_Latency_2 #define SDCLOCK_PERIOD FMC_SDClock_Period_2 /* Default configuration used with LCD */ #define SDRAM_READBURST FMC_Read_Burst_Enable /* The relevant definition of FMC SDRAM mode configuring register */ #define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) #define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) #define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) #define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) #define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) #define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) #define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) #define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) #define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) #define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) #define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) /******************************************************************/ /* A row colunm address signal line */ #define FMC_A0_GPIO_PORT GPIOF #define FMC_A0_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A0_GPIO_PIN GPIO_Pin_0 #define FMC_A0_PINSOURCE GPIO_PinSource0 #define FMC_A0_AF GPIO_AF_FMC #define FMC_A1_GPIO_PORT GPIOF #define FMC_A1_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A1_GPIO_PIN GPIO_Pin_1 #define FMC_A1_PINSOURCE GPIO_PinSource1 #define FMC_A1_AF GPIO_AF_FMC #define FMC_A2_GPIO_PORT GPIOF #define FMC_A2_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A2_GPIO_PIN GPIO_Pin_2 #define FMC_A2_PINSOURCE GPIO_PinSource2 #define FMC_A2_AF GPIO_AF_FMC #define FMC_A3_GPIO_PORT GPIOF #define FMC_A3_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A3_GPIO_PIN GPIO_Pin_3 #define FMC_A3_PINSOURCE GPIO_PinSource3 #define FMC_A3_AF GPIO_AF_FMC #define FMC_A4_GPIO_PORT GPIOF #define FMC_A4_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A4_GPIO_PIN GPIO_Pin_4 #define FMC_A4_PINSOURCE GPIO_PinSource4 #define FMC_A4_AF GPIO_AF_FMC #define FMC_A5_GPIO_PORT GPIOF #define FMC_A5_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A5_GPIO_PIN GPIO_Pin_5 #define FMC_A5_PINSOURCE GPIO_PinSource5 #define FMC_A5_AF GPIO_AF_FMC #define FMC_A6_GPIO_PORT GPIOF #define FMC_A6_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A6_GPIO_PIN GPIO_Pin_12 #define FMC_A6_PINSOURCE GPIO_PinSource12 #define FMC_A6_AF GPIO_AF_FMC #define FMC_A7_GPIO_PORT GPIOF #define FMC_A7_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A7_GPIO_PIN GPIO_Pin_13 #define FMC_A7_PINSOURCE GPIO_PinSource13 #define FMC_A7_AF GPIO_AF_FMC #define FMC_A8_GPIO_PORT GPIOF #define FMC_A8_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A8_GPIO_PIN GPIO_Pin_14 #define FMC_A8_PINSOURCE GPIO_PinSource14 #define FMC_A8_AF GPIO_AF_FMC #define FMC_A9_GPIO_PORT GPIOF #define FMC_A9_GPIO_CLK RCC_AHB1Periph_GPIOF #define FMC_A9_GPIO_PIN GPIO_Pin_15 #define FMC_A9_PINSOURCE GPIO_PinSource15 #define FMC_A9_AF GPIO_AF_FMC #define FMC_A10_GPIO_PORT GPIOG #define FMC_A10_GPIO_CLK RCC_AHB1Periph_GPIOG #define FMC_A10_GPIO_PIN GPIO_Pin_0 #define FMC_A10_PINSOURCE GPIO_PinSource0 #define FMC_A10_AF GPIO_AF_FMC #define FMC_A11_GPIO_PORT GPIOG #define FMC_A11_GPIO_CLK RCC_AHB1Periph_GPIOG #define FMC_A11_GPIO_PIN GPIO_Pin_1 #define FMC_A11_PINSOURCE GPIO_PinSource1 #define FMC_A11_AF GPIO_AF_FMC /* BA address line */ #define FMC_BA0_GPIO_PORT GPIOG #define FMC_BA0_GPIO_CLK RCC_AHB1Periph_GPIOG #define FMC_BA0_GPIO_PIN GPIO_Pin_4 #define FMC_BA0_PINSOURCE GPIO_PinSource4 #define FMC_BA0_AF GPIO_AF_FMC #define FMC_BA1_GPIO_PORT GPIOG #define FMC_BA1_GPIO_CLK RCC_AHB1Periph_GPIOG #define FMC_BA1_GPIO_PIN GPIO_Pin_5 #define FMC_BA1_PINSOURCE GPIO_PinSource5 #define FMC_BA1_AF GPIO_AF_FMC /* DQ data signal line */ #define FMC_D0_GPIO_PORT GPIOD #define FMC_D0_GPIO_CLK RCC_AHB1Periph_GPIOD #define FMC_D0_GPIO_PIN GPIO_Pin_14
上一篇:STM32F429 >> 22. FMC_扩展外部SDRAM(一)
下一篇:STM32 >> 矩阵键盘(代码风格优美,简明易懂)
设计资源 培训 开发板 精华推荐
- LT8606IMSE 1.8V、2MHz 降压型稳压器的典型应用电路
- LT3091HFE 线性稳压器的典型应用,使用较低值的 RSET 以实现较高的输出电压
- #第八届立创电赛#地平线专用方向盘手柄
- DAPLINK+STM32F1:STM32F103C8T6最小系统板,具备DAPLINK功能
- AM3GH-1205DZ ±5V DC/DC转换器的典型应用
- 使用 NXP Semiconductors 的 MCF51JF128VLH 的参考设计
- MIKROE-3523,用于 STM32 STM32F030RC 的 MCU 卡 7
- 使用 ON Semiconductor 的 FAN2501 的参考设计
- 使用 Analog Devices 的 ADN2812 的参考设计
- 使用 Panasonic 的 AN30888B 的参考设计