PSRAM

PSRAM is a memory type that combines the advantages of DRAM and SRAM, with the ease of use of SRAM and the cost-effectiveness of DRAM. Compared to SRAM, PSRAM is slightly slower but has lower cost and power consumption; compared to Flash, PSRAM is faster but lacks non-volatility. PSRAM is suitable for scenarios requiring relatively fast storage speeds. Currently, RTL87x2G cannot use external PSRAM, however, some models of the RTL87x2G series feature MCM PSRAM with the model number W955D8MKY. When using it, developers can refer to the datasheet of the corresponding model of RTL876x2G to confirm whether PSRAM is supported. The following text introduces the usage of PSRAM.

Initialization Steps

  1. Setting the power-on option for PSRAM in config file. When PSRAM Power Supply is set to Enable, it will internally supply 1.8V power to the PSRAM. Otherwise, the PSRAM will be in a power-off state, consuming no power.

../../../../_images/Config_File_Setting.png

Config File Setting

  1. Defining the macro USE_PSRAM ( #define USE_PSRAM 1 ) in mem_config.h will automatically invoke the psram_winbond_opi_init() to complete the initialization settings for PSRAM.

  2. After initialization, the default PSRAM clock is set to 20MHz. Developers can invoke the function fmc_psram_clock_switch() to switch the PSRAM clock. It is generally recommended to directly switch to PSRAM 80MHz. Details and examples are as follows:

    Function Name

    fmc_psram_clock_switch

    Function Prototype

    bool fmc_psram_clock_switch(PSRAM_IDX_TYPE idx, uint32_t required_mhz, uint32_t *actual_mhz)

    Function Description

    set PSRAM clock

    Input Parameter

    required_mhz: twice the target speed of PSRAM clock (maximum setting is 160MHz, corresponding to 80MHz for PSRAM

    actual_mhz: return the actual switched value, where actual_mhz equals required_mhz in the case of a successful clock switch

    Prerequisite

    None

    uint32_t actual_mhz;
    fmc_psram_clock_switch(PSRAM_IDX_SPIC1, 160, &actual_mhz);
    

Read and Write Operations

The method of reading and writing PSRAM is the same as that for SRAM, where direct access to PSRAM addresses (using functions like memcpy and memset) is used without the need for a driver. Here is an example:

#define PSRAM_ADDR        0x08000000
#define TEST_ADDR         0x00100000
memcpy((uint8_t *) PSRAM_ADDR, (uint8_t *) TEST_ADDR, 1024);   // write

Note

The PSRAM model only supports W955D8MKY, with a starting address of 0x8000000 and a size of 4MB.

Low Power Mode Setting

PSRAM offers two low power modes:

  • DPD (Deep Power Down) mode
    If using DPD mode, all content in PSRAM will be lost when entering system low power mode (DLPS).
  • Hybrid Sleep mode
    If Hybrid Sleep mode is used, developers can select parts of the PSRAM to retain, and power consumption will be relatively increased.

For developer convenience, the low power settings for PSRAM are integrated into the system’s low power mode. Developers can modify the following two sections to select the desired PSRAM low power mode.

  1. Add #define USE_PSRAM_DEEP_POWER_HALF_SLEEP_MODE 1 in io_dlps.c to select the Hybrid Sleep mode; otherwise, the DPD mode will be used.

  2. If developers select the Hybrid Sleep mode, they can modify the second parameter of the function fmc_psram_wb_set_partial_refresh() in io_dlps.c to choose the region where the content is not lost after entering system low power mode.

    Function Name

    fmc_psram_wb_set_partial_refresh

    Function Prototype

    bool fmc_psram_wb_set_partial_refresh(FMC_FLASH_NOR_IDX_TYPE idx, FMC_PSRAM_WB_PARTIAL_ARRAY_REFRESH partial)

    Function Description

    Configure certain regions of PSRAM to retain their content after entering and exiting low-power mode

    Input Parameter

    FMC_FLASH_NOR_IDX_TYPE: the default value is FMC FLASH NOR IDX1.

    FMC_PSRAM_WB_PARTIAL_ARRAY_REFRESH: the following values can be set.

    • FMC_PSRAM_WB_REFRESH_FULL

    • FMC_PSRAM_WB_REFRESH_BOTTOM_1_2

    • FMC_PSRAM_WB_REFRESH_BOTTOM_1_4

    • FMC_PSRAM_WB_REFRESH_BOTTOM_1_8

    • FMC_PSRAM_WB_REFRESH_TOP_1_2

    • FMC_PSRAM_WB_REFRESH_TOP_1_4

    • FMC_PSRAM_WB_REFRESH_TOP_1_8

    Prerequisite

    None

    Note

    The larger region retention, the higher power consumption.

    Example usage: (In the example, Hybrid Sleep mode is selected, and the PSRAM retention area is the second half of the region)

    #define USE_PSRAM_DEEP_POWER_HALF_SLEEP_MODE  1
    
    #if USE_PSRAM
    #if USE_PSRAM_DEEP_POWER_HALF_SLEEP_MODE
       fmc_psram_wb_set_partial_refresh(FMC_FLASH_NOR_IDX1, FMC_PSRAM_WB_REFRESH_TOP_1_2);
       fmc_psram_enter_lpm(FMC_FLASH_NOR_IDX1, FMC_PSRAM_LPM_HALF_SLEEP_MODE);
    #else
       fmc_psram_enter_lpm(FMC_FLASH_NOR_IDX1, FMC_PSRAM_LPM_DEEP_POWER_DOWN_MODE);
    #endif
    
    #else
       shut_down_spic_pad_imp(FMC_FLASH_NOR_IDX1, true);
    
    #endif
    

Power Consumption Data

The power consumption data for W955D8MKY is shown in the following table, with a working voltage of 1.8V.

power consumption data

Power mode

Retention region

Current(uA)

Hybrid Sleep mode

Full Array

20

Bottom 1/2 Array

18

Bottom 1/4 Array

16

Bottom 1/8 Array

15

Top 1/2 Array

18

Top 1/4 Array

16

Top 1/8 Array

15

Deep power down mode

0~0.2