cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F767 External SRAM

M N
Associate II
Posted on June 30, 2018 at 18:33

Hi .

I have a custom board with ''stm32f767'' mcu on it and an external sram ''is62wv51216bll-55tli ''.

I have two problem first is when MPU is Disable and i have this config :↓

  SCB_EnableICache();

  SCB_EnableDCache();

.

.

.

/* FMC initialization function */

static void MX_FMC_Init(void)

{

  FMC_NORSRAM_TimingTypeDef Timing;

  /** Perform the SRAM1 memory initialization sequence

  */

  hsram1.Instance = FMC_NORSRAM_DEVICE;

  hsram1.Extended = FMC_NORSRAM_EXTENDED_DEVICE;

  /* hsram1.Init */

  hsram1.Init.NSBank = FMC_NORSRAM_BANK1;

  hsram1.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;

  hsram1.Init.MemoryType = FMC_MEMORY_TYPE_SRAM;

  hsram1.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16;

  hsram1.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_ENABLE;

  hsram1.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;

  hsram1.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;

  hsram1.Init.WriteOperation = FMC_WRITE_OPERATION_DISABLE;

  hsram1.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;

  hsram1.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;

  hsram1.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_ENABLE;

  hsram1.Init.WriteBurst = FMC_WRITE_BURST_ENABLE;

  hsram1.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY;

  hsram1.Init.WriteFifo = FMC_WRITE_FIFO_ENABLE;

  hsram1.Init.PageSize = FMC_PAGE_SIZE_NONE;

  /* Timing */

  Timing.AddressSetupTime = 15;

  Timing.AddressHoldTime = 15;

  Timing.DataSetupTime = 255;

  Timing.BusTurnAroundDuration = 15;

  Timing.CLKDivision = 10;

  Timing.DataLatency = 17;

  Timing.AccessMode = FMC_ACCESS_MODE_A;

  /* ExtTiming */

  if (HAL_SRAM_Init(&hsram1, &Timing, NULL) != HAL_OK)

  {

    _Error_Handler(__FILE__, __LINE__);

  }

}

Then result will be this ↓ (MY_SRAM_BASE_ADDRESS  =0x60000000 as datasheet said ) :

0690X0000060LYpQAM.png

MCU will write to the external sram untill 0x60002577 (usually after reset write until here or a little less)... as you can see i putted a HAL_Delay(1) ms after writing to address if i remove it MCU will write to sram just a little something about 0x60000040 and in both case it generate hard fault error after some writing to sram ( i also am able to read this content).

so does any one has an idea ? what is wrong ? why it can't write in  whole of my sram ? why when i delete delay it write less ?

and second problem is when i Enable MPU in first try to writing to sram it generate hardfault error . (MPU config :↓ :(

/* MPU Configuration */

void MPU_Config(void)

{

  MPU_Region_InitTypeDef MPU_InitStruct;

  /* Disables the MPU */

  HAL_MPU_Disable();

    /**Initializes and configures the Region and the memory to be protected

    */

  MPU_InitStruct.Enable = MPU_REGION_ENABLE;

  MPU_InitStruct.Number = MPU_REGION_NUMBER0;

  MPU_InitStruct.BaseAddress = 0x60000000;

  MPU_InitStruct.Size = MPU_REGION_SIZE_4MB;

  MPU_InitStruct.SubRegionDisable = 0x0;

  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;

  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;

  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

  MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;

  MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;

  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

  HAL_MPU_ConfigRegion(&MPU_InitStruct);

  /* Enables the MPU */

  HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);

}

10 REPLIES 10
Posted on June 30, 2018 at 22:39

Might want to review exactly what the Hard Fault is complaining about. Like F7 DISCO/EVAL boards with working external RAM examples.

Would suggest using

FMC_NORSRAM_TimingTypeDef Timing = {0};

to clear any random stack junk from the structure, and make sure you're filling all the appropriate fields, including any related to size/geometry

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 01, 2018 at 13:46

thank you but did not help that much, hardfault is because of AXI bus error and i don't know why exactly is happening ! the problem is i can write to any address of my external sram but just a couple of byte if i want to write a lot of byte this problem will happen ( in case one MPU disable).

Posted on July 01, 2018 at 16:44

hsram1.Init.WriteOperation = FMC_WRITE_OPERATION_DISABLE; // This is going to be an issue

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 01, 2018 at 18:00

Yep it was a problem thank you again but now there is another problem ?

0690X0000060LZEQA2.png

look at the result and compare it with the first result in original post ... now i can write to whole sram address continusly but it seems upper byte won't work!(won't write 34  just will write 12 on sram ) but in first example it will write 1234 if you see . so i don't think it has pin problem . do you have any idea ?

204263CGIL5
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
204264CGIL5
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 01, 2018 at 18:37

Adding multi answers to avoid moderation hold

IS66WV51216EBLL-55BLI

STM32Cube_FW_F7_V1.11.0\Drivers\BSP\STM32F723E-Discovery\stm32f723e_discovery_psram.c

/**

  * @brief  Initializes the PSRAM device.

  * @retval PSRAM status

  */

uint8_t BSP_PSRAM_Init(void)

{

  static FMC_NORSRAM_TimingTypeDef Timing;

  static uint8_t psram_status = PSRAM_ERROR;

  /* PSRAM device configuration */

  psramHandle.Instance = FMC_NORSRAM_DEVICE;

  psramHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE;

  /* PSRAM device configuration */

  /* Timing configuration derived from system clock (up to 216Mhz)

     for 108Mhz as PSRAM clock frequency */

  Timing.AddressSetupTime      = 9;

  Timing.AddressHoldTime       = 2;

  Timing.DataSetupTime         = 6;

  Timing.BusTurnAroundDuration = 1;

  Timing.CLKDivision           = 2;

  Timing.DataLatency           = 2;

  Timing.AccessMode            = FMC_ACCESS_MODE_A;

  psramHandle.Init.NSBank             = FMC_NORSRAM_BANK1;

  psramHandle.Init.DataAddressMux     = FMC_DATA_ADDRESS_MUX_DISABLE;

  psramHandle.Init.MemoryType         = FMC_MEMORY_TYPE_SRAM;

  psramHandle.Init.MemoryDataWidth    = PSRAM_MEMORY_WIDTH;

  psramHandle.Init.BurstAccessMode    = PSRAM_BURSTACCESS;

  psramHandle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;

  psramHandle.Init.WaitSignalActive   = FMC_WAIT_TIMING_BEFORE_WS;

  psramHandle.Init.WriteOperation     = FMC_WRITE_OPERATION_ENABLE;

  psramHandle.Init.WaitSignal         = FMC_WAIT_SIGNAL_DISABLE;

  psramHandle.Init.ExtendedMode       = FMC_EXTENDED_MODE_DISABLE;

  psramHandle.Init.AsynchronousWait   = FMC_ASYNCHRONOUS_WAIT_DISABLE;

  psramHandle.Init.WriteBurst         = PSRAM_WRITEBURST;

  psramHandle.Init.WriteFifo          = FMC_WRITE_FIFO_DISABLE;

  psramHandle.Init.PageSize           = FMC_PAGE_SIZE_NONE;

  psramHandle.Init.ContinuousClock    = CONTINUOUSCLOCK_FEATURE;

  /* PSRAM controller initialization */

  BSP_PSRAM_MspInit(&psramHandle, NULL); /* __weak function can be rewritten by the application */

  if(HAL_SRAM_Init(&psramHandle, &Timing, &Timing) != HAL_OK)

  {

    psram_status = PSRAM_ERROR;

  }

  else

  {

    psram_status = PSRAM_OK;

  }

  return psram_status;

}

&sharpdefine PSRAM_DEVICE_ADDR  ((uint32_t)0x60000000)

&sharpdefine PSRAM_DEVICE_SIZE  ((uint32_t)0x80000)  /* SRAM device size in Bytes */

/* &sharpdefine SRAM_MEMORY_WIDTH    FMC_NORSRAM_MEM_BUS_WIDTH_8*/

&sharpdefine PSRAM_MEMORY_WIDTH    FMC_NORSRAM_MEM_BUS_WIDTH_16

&sharpdefine PSRAM_BURSTACCESS     FMC_BURST_ACCESS_MODE_DISABLE

/* &sharpdefine PSRAM_BURSTACCESS     FMC_BURST_ACCESS_MODE_ENABLE*/

&sharpdefine PSRAM_WRITEBURST      FMC_WRITE_BURST_DISABLE

/* &sharpdefine PSRAM_WRITEBURST     FMC_WRITE_BURST_ENABLE */

&sharpdefine CONTINUOUSCLOCK_FEATURE    FMC_CONTINUOUS_CLOCK_SYNC_ONLY

/* &sharpdefine CONTINUOUSCLOCK_FEATURE     FMC_CONTINUOUS_CLOCK_SYNC_ASYNC */
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 02, 2018 at 17:15

the connection are right is just 19 address and 16 data pin and some cmd pin im sure about it . there would be something else when i put  these value :

   Timing.AddressSetupTime = 0;

  Timing.AddressHoldTime = 0;

  Timing.DataSetupTime = 2;

 and turn of the mpu i can write to sram for something about 3000 byte with valid data but when i change this parameter everything will corrupt and also with these value i also am able to write just 3000 byte by valid data then it will corrupt again .

Posted on July 02, 2018 at 17:19

why pin address 18 is connected to ground in this SCH ? in my Schematic it is connected to MCU as IS62SRAM data sheet said . (actually didn't see anything about connect this pin to ground or other note about pins . )