|
FMC—读写SDRAM-W9825G6KH-6
一些注意事项,后面直接看代码
1、W9825G6KH是行地址(row)13bit,列地址(column)9bit,数据16位,4banks,总共32M字节,166MHz/CL3 or 133MHz/CL2,0°C ~ 70°C。
2、可配置为SDRAM1或SDRAM2,SDRAM1地址为0xC0000000,SDRAM2地址为0xD0000000。
3、配置为SDRAM1或2,需与后面配置的自刷新BANK号需一致,否则读写不到数据。
4、地址宽度要配置正确,否则读写会卡死。
5、配置的SDRAM时钟为2分频,即216M/2=108M,一个周期为1000/109=9.259ns==9.3ns。
缩写解析:
CL = CAS Latency
tRSC = Mode register Set Cycle Time, 加载模式寄存器命令后的延迟
tXSR = Exit self refresh to ACTIVE command, 自刷新命令后的延迟
tRAS = Active to precharge Command Period, 自刷新时间
tRC = Ref/Active to Ref/Active Command Period, 行循环延迟
tWR =Write Recovery Time,恢复延迟
tRP = Precharge to Active Command Period, 行预充电延迟
tRCD = Active to Read/Write Command Delay Time, 行到列延迟
SdramTiming.LoadToActiveDelay = 2; = tMRD或tRSC, = 2 tCK, 即最少2个时钟周期
SdramTiming.ExitSelfRefreshDelay = 8; = tXSR, = 72ns, 此处8*9.3=74ns。
SdramTiming.SelfRefreshTime = 5; = tRAS, = 42ns, 此处5*9.3=46.5ns。
SdramTiming.RowCycleDelay = 7; = tRC, = 60ns, 此处7*9.3=65ns。
SdramTiming.WriteRecoveryTime = 2; = tWR, =2 tCK,即最少2个时钟周期
SdramTiming.RPDelay = 2; = tRP, = 15ns,此处2*9.3=18ns。
SdramTiming.RCDDelay = 2; = tRCD, = 15ns,此处2*9.3=18ns。
配置上电时序,需在SDRAM配置后再调用。
- void SDRAM_Init_Sequence(uint32_t RefreshCount)
- {
- __IO uint32_t tmpmrd = 0;
- FMC_SDRAM_CommandTypeDef Command;
-
- /* Step 1: Configure a clock configuration enable command */
- Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
- Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
- Command.AutoRefreshNumber = 1;
- Command.ModeRegisterDefinition = 0;
- /* Send the command */
- HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
- /* Step 2: Insert 100 us minimum delay */
- /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
- HAL_Delay(100);
-
- /* Step 3: Configure a PALL (precharge all) command */
- Command.CommandMode = FMC_SDRAM_CMD_PALL;
- Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
- Command.AutoRefreshNumber = 1;
- Command.ModeRegisterDefinition = 0;
- /* Send the command */
- HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
-
- /* Step 4: Configure an Auto Refresh command */
- Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
- Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
- Command.AutoRefreshNumber = 8;
- Command.ModeRegisterDefinition = 0;
- /* Send the command */
- HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
-
- /* Step 5: Program the external memory mode register */
- tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |\
- SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\
- SDRAM_MODEREG_CAS_LATENCY_3 |\
- SDRAM_MODEREG_OPERATING_MODE_STANDARD |\
- SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;
-
- Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
- Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
- Command.AutoRefreshNumber = 1;
- Command.ModeRegisterDefinition = tmpmrd;
- /* Send the command */
- HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
-
- /* Step 6: Set the refresh rate counter */
- /* Set the device refresh rate */
- HAL_SDRAM_ProgramRefreshRate(&hsdram1, RefreshCount);
- }
复制代码
CUBEMX配置
时序表
测试结果
工程代码:
F750_SDRAM.rar
(965.19 KB, 下载次数: 1544)
|
|