Skip to main content
M N
Associate III
Jun 30, 2018 4:33 PM UTC
Question

STM32F767 External SRAM

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);

}

    This topic has been closed for replies.

    10 replies

    Tesla DeLorean
    Guru
    Jun 30, 2018 8:39 PM UTC
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    M N
    M NAuthor
    Associate III
    Jul 1, 2018 1:46 PM UTC
    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).

    Tesla DeLorean
    Guru
    Jul 1, 2018 4:44 PM UTC
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..