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

initialized peripheral current draw after uninitialized

I'm working with a custom board that is using a nrf53840. The SDK is 16.0 and SoftDevice S140 version 7.0.1. Programming with SES. The board has various devices such as accelerometers, temperature, etc... communicating with the 52840 via SPI, I2C, and I2S. Because my principle application uses DFU and BLE, a secure boot loader and the Softdevice reside in memory. Neither are used in the current discussion.

I want to measure the quiescent current. I'm using an Otii to measure the current consumption.

main:

#include "si7210_thing/si7210_twi.h"



int main(void)
{

    uint32_t        err_code;
    uint8_t         id_value;

    //si7210_twi_sleep();
    //si7210_twi_master_init();
    //si7210_twi_put_to_sleep_no_measure();
    //si7210_twi_master_uninit();

    //NRF_CLOCK->TASKS_HFCLKSTOP = 1;
    NRF_POWER->SYSTEMOFF = 1;

    for (; ; )
    {
        __WFE();
    }

}

With the TWI peripheral's functions commented out, the board is consuming 113uA in systemoff. That indicates the peripheral devices are consuming power and need to be initialized and put to sleep.

So I start with the Si7210 which communicates with the nrf53840 via TWI. As you can see in the code, I've tried a couple of things. My first effort used the single function si7210_twi_sleep. When that had power issues, I thought to break its functionality up into three functions and test the power consumption when completing separate tasks.

I can use the functions si7210_twi_master_init and si7210_twi_master_uninit by themselves and do no TWI communications. When I do that the board's current consumption remains the same at 113uA as expected. When I use the function si7210_twi_put_to_sleep_no_measure, the board consumes 633uA in sleep mode. That function does two rx and two tx to configure two registers with appropriate values to put the si7210 completely asleep. From researching the devzone, I've concluded that the extra 520uA is because the HF clock is running.

It seems that any use of nrf_drv_twi_tx or nrf_drv_twi_rx triggers the HF clock but simply using nrf_drv_twi_uninit doesn't shut it down.

My question is how do I use a peripheral like TWI or SPI or I2S and then shut it down so that all the resources the peripheral was using are also stopped ?

Parents
  • Hello,

    That indicates the peripheral devices are consuming power and need to be initialized and put to sleep.

     Just to confirm, is this referring to external sensors, or on-chip peripherals. And it if it's external sensors, are they always powered? I'm basically asking if there is a chance you may have leakage current going through these.I would expect the current going into the nRF52840 to be around 0.4 uA with the code snippet you posted (i.e assuming no IO or peripheral initialization, just entering system OFF).

    The TWIM should not impact the base current once all transactions are completed. The peripheral should be powered down automatically by the power management unit. That's also my experience.

    Best regards,

    Vidar

Reply
  • Hello,

    That indicates the peripheral devices are consuming power and need to be initialized and put to sleep.

     Just to confirm, is this referring to external sensors, or on-chip peripherals. And it if it's external sensors, are they always powered? I'm basically asking if there is a chance you may have leakage current going through these.I would expect the current going into the nRF52840 to be around 0.4 uA with the code snippet you posted (i.e assuming no IO or peripheral initialization, just entering system OFF).

    The TWIM should not impact the base current once all transactions are completed. The peripheral should be powered down automatically by the power management unit. That's also my experience.

    Best regards,

    Vidar

Children
  • Thank you. In the quoted sentence, peripheral devices means the external sensors. Yes, they are always powered.

    So, even if I leave TWI initialized and enabled, TWI and the resources it uses would be shutdown as soon as I enter system off? In system off, the nRF52840 isn't using any thing, In fact, by entering system off I can't inadvertently leave any nRF52840 resource/peripheral running?

    (i.e assuming no IO or peripheral initialization, just entering system OFF).

    Does my code snippet contain IO or peripheral initialization? I suppose the #include could eventually lead to IO or peripheral initialization. Although in this case I don't think it does. What I'm trying to get at is if I were to run just the following code

    int main(void)
    {
    
        NRF_POWER->SYSTEMOFF = 1;
    
        for (; ; )
        {
            __WFE();
        }
    
    }
    

    I should see a more or less flat line on my Otii at about 0.4 uA, given an ideal world. Anything more than 0.4uA is an indication of current use by the rest of the board? The nRF52840 is consuming 0.4uA, (I would add that the nRF52840 is part of a BMD340).

  • Thanks for confirming. So I would have expected the current draw to be 0.4 uA if it was isolated to the nRF device. The chip is nearly powered off in this mode so peripherals and clock sources are all automatically powered down by the system. The only two things the application should make sure of before entering system off is that there are no ongoing DMA transactions and to re-configure used IOs if necessary (GPIO settings are retained in system OFF).

    Do the external sensors have inputs that may become floating? I'm wondering if the leakage may possibly be caused by that? It's ok to leave nRF IOs floating when they are configured to their reset state (input/disconnect) but other chips may require a constant pull-up, etc. If the i2c bus doesn't have external pull-ups mounted, maybe you can try to enable the internal pull-ups on the nRF before entering sleep and see if that helps.

Related