最近刚接触到sram,用的是256K*16bits的,芯片为ZET6,根据ST公司提供的关于FSMC的库文件,然后自己copy了一下,但是读出的数据和写进去的数据不一样,读出的数据比写进去的数据大了0x000c,由于是16位的数据,所以以字为最小单位,现在都不知道问题在哪里,希望各位根据自己的经验帮忙分下一下问题可能出在什么地方,板子我用万用表测了,没问题!
另外请教一下,sram是不是和eeprom寻址读数不太一样,并不是将其分为多少页,每页多少字节来操作的?!然后256K*16bits的sram需要18根地址线进行寻址,在STM32中,为什么不管数据多少位,FSMC_A[0]始终应该连到外部存储器的地址线A[0]?
FSMC的配置代码如下,基本上都是根据库提供的,希望大家帮我看下配置是否有问题,谢谢:
void FSMC_sram_Device_Init(void)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; //定义结构体用来设置FSMC的相关信息
FSMC_NORSRAMTimingInitTypeDef SRAM_TimingInitStructure; //定义读写模式相关时间的初始化的结构体,可以通过STM32参考手册查得相关信息
SRAM_TimingInitStructure.FSMC_AddressSetupTime = 5;
SRAM_TimingInitStructure.FSMC_AddressHoldTime = 5;
SRAM_TimingInitStructure.FSMC_DataSetupTime = 2;
SRAM_TimingInitStructure.FSMC_BusTurnAroundDuration = 0;
SRAM_TimingInitStructure.FSMC_CLKDivision = 0;
SRAM_TimingInitStructure.FSMC_DataLatency = 0;
SRAM_TimingInitStructure.FSMC_AccessMode = FSMC_AccessMode_A;
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &SRAM_TimingInitStructure;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &SRAM_TimingInitStructure;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE);
}
|