AnsweredAssumed Answered

STM32F103ZD FSMC_MemoryDataWidth_16b writes 32 bits instead of 16

Question asked by kilic.orcun on Sep 10, 2015
Latest reply on Sep 11, 2015 by kilic.orcun

I'm using a STM32F103ZD in my project to communicate with a SRAM FPGA which has a datawidth of 16 bits. When the STM32 writes or reads from FPGA, it reads 16 bits of data, let's say 0x05 but while debugging, I see in FSMC memory (0x60000000) 00050005 instead of 00000005. So it reads 2x16 bits of the same data. FPGA cant be the problem because it works with another Arm A9 processor(which has a parallel bus interface similar to but other than FSMC). I checked all pin configurations and they are correct. Here is how I initialize FSMC and write into it:

   FSMC_NORSRAMTimingInitTypeDef FSMC_NORSRAMTimingInitStructure;

   FSMC_NORSRAMTimingInitStructure.FSMC_AddressSetupTime = 0x03;
   FSMC_NORSRAMTimingInitStructure.FSMC_AddressHoldTime = 0x0F;
   FSMC_NORSRAMTimingInitStructure.FSMC_DataSetupTime = 0x04;
   FSMC_NORSRAMTimingInitStructure.FSMC_AccessMode = FSMC_AccessMode_A;
   FSMC_NORSRAMTimingInitStructure.FSMC_BusTurnAroundDuration = 0;     // Only used with NOR Flash
   FSMC_NORSRAMTimingInitStructure.FSMC_CLKDivision = 0;     // Not used for Nor or SRAM
   FSMC_NORSRAMTimingInitStructure.FSMC_DataLatency = 0;     // Don't care with Nor or SRAM

   FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
   FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
   FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
   FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;
   FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;
   FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
   FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; // Only valid for flash memory in burst mode (just default)
   FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; // Only valid for burst memories (just default)
   FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; // Only valid for flash memory in burst mode (just default)
   FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
   FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
   FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
   FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
   FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;

// Enable FSMC Bank1_SRAM Bank

I have a struct called FSMC_STRUCT and it has a lot of 16bit arrays in it to make understanding address offsets easier. FSMC_NOR_BANK1 = 0x60000000
fsmc_pointer->structx[0] = 0x01 for example writes a 0x01 into the address of structx[0] which is 0x60000000 BUT also into adress of structx[1] which is 0x60000002. And if I write something in structx[1], it will also be written in the address of structx[0] in FSMC.
so in debug the addresses 0x60000000 and 0x60000002 hold 0x00010001 but I only wrote in one of them. What could be the cause of this problem? Thank you very much in advance