HAL SRAM How to Use

group SRAM_How_To_Use

How to use the SRAM HAL module driver

The FMC SRAM main features :

This SRAM HAL driver is a generic driver which contains a set of APIs used to configure the FMC SRAM sub-banks to interface with SRAM, PSRAM and CRAM memories.

The FMC SRAM peripheral supports the following read and write access modes :

  • SRAM memories :

    • Asynchronous read and asynchronous write with identical timing for both operations.

    • Asynchronous read and asynchronous write with distinct timing for each operation.

  • PSRAM/CRAM memories :

    • Asynchronous read and asynchronous write with identical timing for both operations.

    • Asynchronous read and asynchronous write with distinct timing for each operation.

    • Synchronous read and synchronous write.

    • Synchronous read and asynchronous write.

    • Asynchronous read and synchronous write.

The FMC SRAM peripheral supports the write protection feature.

The SRAM HAL driver can be used as follows :

This module provides 5 different set of APIs that allows to :

  • Initialize and de-initialize the logical FMC SRAM object ( hal_sram_handle_t ) :

    • Initialize the logical FMC SRAM object and associate it to a physical instance (sub-bank). This functionality is ensured by HAL_SRAM_Init() function.

    • De-initialize the logical FMC SRAM object and disable the SRAM sub-bank. This functionality is ensured by HAL_SRAM_DeInit() function.

  • Configure the FMC SRAM to be ready to use and retrieve the current configuration :

    • Configure the FMC SRAM through three steps by following the order below :

      • Step 1 (FMC configuration) : is the first step to perform once the HAL SRAM driver is initialized. This functionality is ensured by HAL_SRAM_SetConfig() function.

        At this stage, the SRAM is partially configured but not yet ready to use.

      • Step 2 (Memory configuration) : is the second step to perform once the FMC is initialized. This functionality is ensured by one of these 5 functions depending on the external device access mode :

      • Step 3 (Memory enable/disable) : is the third step to perform once the SRAM is fully configured. This functionality is ensured by HAL_SRAM_EnableMemory() and HAL_SRAM_DisableMemory() functions.

        • HAL_SRAM_EnableMemory() : function to enable the SRAM sub-bank and make it accessible for read and write operations.

        • HAL_SRAM_DisableMemory() : function to disable the SRAM sub-bank which is useful when memory configuration adjustments are needed. After making the necessary adjustments, the HAL_SRAM_EnableMemory() must be recalled to enable the memory and make it accessible.

          At this stage, the SRAM is fully configured, enabled and ready for use.

    • Retrieve the current configuration through the following functions :

      • Retrieve the FMC configuration : This functionality is ensured by HAL_SRAM_GetConfig() .

      • Retrieve the memory configuration : This functionality is ensured by one of these 5 functions depending on the external device access mode :

  • Manage the FMC SRAM peripheral access when it is fully configured :

  • Store and retrieve user data :

  • Retrieve the HAL SRAM state and clock frequency :

  • The read and write process must be managed within the application side (outside the HAL SRAM module) after fully configuring the FMC SRAM.