|
本帖最后由 missinlite 于 2025-6-10 15:12 编辑
问题解决:Solved: Missing SDNWE signal using STM32F469NI and SDRAM o... - STMicroelectronics Community
F469/479系列手册和CUBEMX中显示fmc_sdnwe可以用PA7和PC0,但是实际上PA7是无效的,只能用PC0,ST官方没有修改手册和CUBEMX的配置
----------------------------------------------------------
鼓捣了好几天没弄明白,发出来球各位大佬指教
使用cubemx生成的FMC初始化,根据网上找的F429驱动同款芯片的资料微调了SDRAM初始化函数
目前现象是,写入test[0],读test[0]能读出写入的数据,然后写入test[1],再次读[0]和[1],读出的都是最后一次写入[1]的数据。
用万用表量引脚,数据和地址脚正常,但是WE脚始终是低电平,看手册上读的时候这个脚应该是高
目前怀疑1.FMC初始化失败,但是这块是CUBE生成的,按理说不应该
2.地址映射有误,目前没有找到F469的映射资料,F429的FMC SDRAMbank2对应的是0xD0000000,查了一下F429和469在地址映射上应该是没有差别的
附上CUBEMX配置情况及SDRAM初始化代码,主频180Mhz,开了FMC中断
void MX_SDRAM_InitEx(void)
{
__IO uint32_t tmpmrd = 0;
FMC_SDRAM_CommandTypeDef Command;
int ret = 0;
/* Step 1: Configure a clock configuration enable command */
Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = 0;
/* Send the command */
while(HAL_SDRAM_GetState(&hsdram1) == HAL_SDRAM_STATE_BUSY)
{
}
ret = HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
printf("SDRAM_Init: Step 1: Configure a clock configuration enable command, ret = %d\r\n", ret);
/* 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_BANK2;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = 0;
while(HAL_SDRAM_GetState(&hsdram1) == HAL_SDRAM_STATE_BUSY)
{
}
/* Send the command */
ret = HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
printf("SDRAM_Init: Step 3: Configure a PALL (precharge all) command, ret = %d\r\n", ret);
HAL_Delay(100);
/* Step 4: Configure an Auto Refresh command */
Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command.AutoRefreshNumber = 8;
Command.ModeRegisterDefinition = 0;
while(HAL_SDRAM_GetState(&hsdram1) == HAL_SDRAM_STATE_BUSY)
{
}
/* Send the command */
ret = HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
printf("SDRAM_Init: Step 4: Configure an Auto Refresh command, ret = %d\r\n", ret);
HAL_Delay(100);
/* Step 5: Program the external memory mode register */
tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_2 |\
SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\
SDRAM_MODEREG_CAS_LATENCY_3 |\
SDRAM_MODEREG_OPERATING_MODE_STANDARD |\
SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED;
Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = tmpmrd;
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
HAL_Delay(100);
/* Step 6: Set the refresh rate counter */
/* Set the device refresh rate */
HAL_SDRAM_ProgramRefreshRate(&hsdram1, 1387);
while(HAL_SDRAM_GetState(&hsdram1) == HAL_SDRAM_STATE_BUSY)
{
}
//HAL_Delay(100);
}
测试部分代码:
u16 testsram[1024] __attribute__((at(0xD0000000))) ;(全局变量)
U16 temp = 0;
//HAL_SDRAM_read_8b(&hsdram1,(uint32_t *)(testsram),(uint8_t *)&temp,1);
printf("read testsram == %d\r\n",testsram[0]);
temp = 123;
HAL_SDRAM_Write_8b(&hsdram1,(uint32_t *)(testsram),(uint8_t *)&temp,1);
//HAL_SDRAM_read_8b(&hsdram1,(uint32_t *)(testsram),(uint8_t *)&temp,1);
printf("22read testsram == %d\r\n",testsram[0]);
testsram[1] = 789;
printf("22read testsram0 == %d testsram1 == %d\r\n",testsram[0],testsram[1]);
|
|