Enable S2R RAM

S2R (Samples to RAM) RAM

The S2R RAM (or S2RRAM) is intended for the radio core to store additional information that it captures from received packets. In the current stack implementation, it is left unused. If the S2R module is not used, the application can use the S2R RAM as an additional 4 kB scratch memory. There are some important limitations described in the list below:

  • The supply for the S2R RAM must be on, and since this is part of the radio module, the radio core must be on as well.

    • This will result in higher current consumption.

    • Since the S2R RAM module is not powered at boot, you cannot place initialized data in S2R RAM, since the auto-initialization sequence at startup will fail.

  • The S2R RAM is not retained through STANDBY.

    • If the application relies on the S2R RAM being retained, it must not put the device in STANDBY for the period that the S2R RAM content must remain coherent. Once exiting STANDBY, new values can be written and read to and from S2R RAM again.

Enabling S2R RAM

The TI provided linker files have memory regions defined for the S2R RAM, and the .s2rram section is placed in this memory region. To place a symbol in S2R RAM the application must place that symbol in the .s2rram section using compiler attributes.

Note

As mentioned above, no initialized data can be placed in S2R RAM, so only uninitialized data may be placed in the .s2rram section. Additionally data placed in .s2rram will not be auto zero-initialized.

The above mentioned limitations and requirements are handled in the s2rram example application: <SDK_INSTALL_DIR>/examples/rtos/<DEVICE>/drivers/s2rram. The key aspects are described in the list below:

  1. In order to place data in the S2R RAM region, the application must declare and place it in the .s2rram section using compiler attributes:

    /* Define buffer to be placed in S2R RAM */
    #ifdef __IAR_SYSTEMS_ICC__
        #pragma location = ".s2rram"
    #elif (defined(__GNUC__) || defined(__clang__))
    __attribute__((section(".s2rram")))
    #else
        #error Unsupported Compiler
    #endif
    volatile uint8_t s2rramBuffer[S2RRAM_BUFFER_SIZE];
    
  2. To be able to read and write to the buffer, the S2R RAM must be clocked. This is achieved by setting a power dependency on the S2R RAM. Once it is no longer needed, the dependency on S2R RAM can be removed.

    /* Ensure that S2R RAM is powered */
    Power_setDependency(PowerLPF3_PERIPH_LFRD_S2RRAM);
    
    // ... S2R RAM dependent application code ...
    
    /* Remove dependency on S2R RAM, once it is not used anymore */
    Power_releaseDependency(PowerLPF3_PERIPH_LFRD_S2RRAM);
    
  3. When performing operations that require S2R RAM retention and may allow the device to enter STANDBY, the application must ensure that the device cannot be put into STANDBY. Otherwise, the verification might fail because the S2R RAM will not be retained. To achieve this, the application may set a power constraint to disallow STANDBY. Once the possible STANDBY region is exited, the power constraint can be released.

    /* Prevent device from entering STANDBY */
    Power_setConstraint(PowerLPF3_DISALLOW_STANDBY);
    
    // ... S2R RAM retention dependent application code ...
    
    /* Release disallow STANDBY constraint */
    Power_releaseConstraint(PowerLPF3_DISALLOW_STANDBY);
    

For more information, please reference the README found in <SDK_INSTALL_DIR>/examples/rtos/<DEVICE>/drivers/s2rram.