This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Powering down RAM sections increases current

Hi, I am trying to measure (and reduce) the current consumption of my board. I am using nrf52832 (64K RAM) for my development. The RAM layout is as follows: RAM (rwx) : ORIGIN = 0x20002080, LENGTH = 0x2EA8. Stack is 2048 and heap is 1024 bytes. Total comes out to be 0x3AA8. Looking at this configuration, I understand that I am using 2 sections of the RAM (section 0 & 1). Hence I am powering down sections 2 to 7. My assumption is that powering down the RAM will reduce my current consumption by some value. But instead of that my current consumption is going into mA. I don't understand what I am doing wrong. I have pasted my code below. Please let me know my mistake.

int main(void)
{
    nrf_clock_lf_cfg_t clock_lf_cfg = {
    .source        = NRF_CLOCK_LF_SRC_RC,
    .rc_ctiv       = 16,
    .rc_temp_ctiv  = 2,
    .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM};

    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);

    for (uint8_t i = 2; i < 8; i++)
    {
            NRF_POWER->RAM[i].POWER = 0;
            NRF_POWER->RAM[i].POWERCLR = 0x00030003;
    }

    sd_power_mode_set(NRF_POWER_MODE_LOWPWR);

    while (true)
    {
            sd_app_evt_wait();
    }

    return 0;
}
  • 0x20002080 + 0x2EA8 = 0x20004F28. So, You are using RAM0-2 blocks. RAM begins at 0x20000000, not 0x20002080. It is 0x20002080 because 0x2080 is reserved for SoftDevice.

  • I'm not sure if I understand your calculations correctly, but anyways, RAM ORIGIN is where the application RAM starts after the Softdevice RAM, and then you have the size of the application RAM.

    So lets say you want to power 2 RAM sections. That equals 16k = 0x4000.

    RAM starts at 0x2000 0000
    Softdevice ends at 0x2000 2080 (This depends on the SD configuration; using the numbers in your question)
    Then you have 0x4000 - 0x2080 = 0x1F80 left for the application.

    So the values in the linker script should then be,

    RAM (rwx) : ORIGIN = 0x20002080, LENGTH = 0x1F80
    

    EDIT

    I ran your code and I got the same result. The problem is that you're turning of RAM after the SOFTDEVICE_HANDLER_INIT(). There's a protection mechanism in the SD. Move the for loop to the start of main() and you should be fine. Or you can use the SD call for turning of RAM, sd_power_ram_power_clr().

  • Hi Wojtek, Thank you for answering. I have modified my code to power down sections 3 to 7. But still my current consumption is in mA. Any ideas on that? I have attached the modified code below.

    int main(void)
    

    { nrf_clock_lf_cfg_t clock_lf_cfg = { .source = NRF_CLOCK_LF_SRC_RC, .rc_ctiv = 16, .rc_temp_ctiv = 2, .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM};

    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    
    for (uint8_t i = 3; i < 8; i++)
    {
            NRF_POWER->RAM[i].POWER = 0;
            NRF_POWER->RAM[i].POWERCLR = 0x00030003;
    }
    
    sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
    
    while (true)
    {
            sd_app_evt_wait();
    }
    
    return 0;
    

    }

    Thanks, SUK

  • Hi Stian, Thank you for your reply. I have modified my code to power only 3 RAM sections and power down the remaining ones. But the current consumption is still high. Any ideas on that? Thanks, SUK

  • Pls post screen of your memory configuration.

Related