__disable_irq() is not working

nRF52832, SDK 13.0, no Softdevice

I had a possible power leakage issue and tried to debug it with Segger Embedded studio.

Please refer to below. 

int main(void)
{
  while(1)
  {
    __disable_irq();
    __WFI();
  };

}

As you can see, there is nothing the CPU is doing. But, I see current of 50~60mA on 4V.

I used Segger Embedded Studio. Is it a project configuration issue? Or, possible HW issue?

Please assist.

  • Hi,

    This must be a HW issue with some other parts of your board drawing current. Here your firmware does absolutely nothing other then enter system on sleep mode, which in itself should consume about 2 uA.

    PS: There is no need to __disable_irq() here as no interrupts have been enabled.

  • Do you think the CPU is in sleep mode?

    When I did debug trace via J-Link, it actually execute next instruction of __WFI();

    It means that there is a interrupt. Am I correct?

    That's why I suspect __disable_irq() is not working.

    Is there a way that I can confirm that there is no interrupt? OR, at least the CPU is in sleep?

    My HW guy is outside of the team and he is claiming the CPU is running and that's why there is current.

    I want to know how to confirm where I can dig into the root cause further.

    Thanks.

  • Hi,

    joojoo5 said:

    When I did debug trace via J-Link, it actually execute next instruction of __WFI();

    It means that there is a interrupt. Am I correct?

    That's why I suspect __disable_irq() is not working.

    It will be affected by the debugger, but will sleep forever when not debugging.

    joojoo5 said:
    Is there a way that I can confirm that there is no interrupt? OR, at least the CPU is in sleep?

    You can test with this code snippet instead (adjust the pin number to a pin you have access to so that you can check with a logic analyzer:

    #define PIN 17
    #define TOGGLE_PIN 1
    
    int main(void)
    {
    #if TOGGLE_PIN
        nrf_gpio_cfg_output(PIN);
        nrf_gpio_pin_set(PIN);
    #endif
    
        while(1)
        {
            __WFE();
    #if TOGGLE_PIN
            nrf_gpio_pin_toggle(PIN);
    #endif
        }
    }

    joojoo5 said:
    My HW guy is outside of the team and he is claiming the CPU is running and that's why there is current.

    That is not the case here. With the CPU running constantly the current consumption would be significantly less than 40 mA, as the CPU run current in LDO mode is about 7.4 mA and this firmware does nothing else.

    joojoo5 said:
    I want to know how to confirm where I can dig into the root cause further.

    First of all, I would double check the measurement setup to verify that you actually measure the current consumption on your board, and that it is not affected by a measuring error. After that, if you need to convince the HW guy to look into the WH you could modify the HW so that all supply or all ground for the nRF is disconnected from the PCB and route it via an ampere meter. That way you can measure the current consumption of only the nRF and not the rest of the board. This would typically involve desoldering specific pins from the board and replace with thin wires, so it requires a trained and steady hand, but it will provide hard "evidence" that there is a need to look at other components on the board.

Related