Spikes in current consumption after using semaphores





can anyone tell me what are these spikes

i am some part of my code:

_SPRINTLN(DEBUG_INFO, "LOW-PWR-SYS-ON"); // debug log to show device will enter standby state

        // turn off peripherals
        pm_device_action_run(uart_dev, PM_DEVICE_ACTION_SUSPEND);
        pm_device_action_run(adc_dev, PM_DEVICE_ACTION_SUSPEND);

        // Block (sleep) the main thread, it will wake up on GPIO interrupt or timer timeout
        k_sem_take(&main_sem, K_FOREVER);

        pm_device_action_run(uart_dev, PM_DEVICE_ACTION_RESUME);
        pm_device_action_run(adc_dev, PM_DEVICE_ACTION_RESUME);

Parents
  • Hello,

    As far as I can tell, you have the same spikes in the first and second screenshot, but that is perhaps what you intended? 

    I need a bit more context. Perhaps you can upload the application you used in your measurements?

    It is an event happening every 4 seconds, so perhaps some timer waking up the CPU every 4 seconds?

    Best regards,

    Edvin

  • Hello Edvin 
    i want to send zip file of my application how can i do that?

  •  
    kindly go through below explanation:


    Description:

    I am working on an application using nRF52811 with a LoRa modem. The application handles two scenarios, Case 1 and Case 2, both leveraging Zephyr and the system off mode for ultra-low power consumption. However, I have observed unexpected behavior regarding current consumption after GPIO interrupts in Case 1.


    Observed Behavior:

    • Case 1: After waking up the main thread via GPIO interrupt and entering system-off mode, the current consumption is 300–450 µA, significantly higher than expected.
    • Case 2: Directly entering system-off mode results in current consumption of ~2.5 µA, which is expected.

    There is a significant difference in current consumption between these two cases in system-off mode.


    Application Details:

    Hardware Setup:

    • nRF52811 microcontroller.
    • LoRa modem connected to the nRF52811.

    Test Code:

    #include "inc/util.h"
    #include "inc/du_radio_hal.h"
    #include <zephyr/kernel.h>
    
    #define CASE 2
    
    int main()
    {
            // Configure LEDs
            led_init();
            // Indicate booting by LEDs
            led_on_boot();
            // Initialize the radio device
            du_radio_init();
            // Initialize GPIO pins and interrupts
            pins_init();
    
            k_sleep(K_SECONDS(5));
    
    #if CASE == 1
            shutdown_cpu(DU_SLEEP_STANDBY);
    
            while (true)
            {
                    shutdown_cpu(DU_SLEEP_SHUTDOWN);
            }
    #elif CASE == 2
            while (true)
            {
                    shutdown_cpu(DU_SLEEP_SHUTDOWN);
            }
    
    #endif
    }
    

    Test Cases:

    Case 1: GPIO Wakeup Path

    1. The main thread sleeps and is configured to wake up via GPIO interrupt.
    2. Upon a button press, the system wakes up and the main thread executes.
    3. After waking, the system is placed into system-off mode using shutdown_cpu(DU_SLEEP_SHUTDOWN).

    Result: Current consumption in system-off mode is ~300–450 µA.

    Case 2: Direct Shutdown

    1. The application directly enters system-off mode without waking the main thread.

    Result: Current consumption in system-off mode is ~2.5 µA.


    Attachments:

    1. Test Code: test-code.zip
    2. Case 1 Current Consumption Measurements: case-1-current.zip
    3. Case 2 Current Consumption Measurements: case-2-current.zip

    Expected Behavior:

    The current consumption in system-off mode for Case 1 should be consistent with Case 2, i.e., ~2.5 µA.


    Possible Cause and Questions:

    1. Could the GPIO wakeup interrupt be leaving peripherals or components (e.g., clocks, peripherals, or the LoRa modem) enabled, causing higher current consumption?
    2. Are there any additional steps required to properly power down the device after a GPIO interrupt?
    3. Is there an internal state in the nRF52811 that might differ between direct shutdown and wake-up via GPIO?

    Request for Help:

    • Guidance on why the current consumption differs between the two cases.
    • Suggestions for debugging and ensuring all peripherals are properly powered down in Case 1.
    • Any specific configurations or settings required in Zephyr to handle GPIO wakeup followed by system-off mode efficiently.




      I hope this will provide some more insights about this issue.
Reply
  •  
    kindly go through below explanation:


    Description:

    I am working on an application using nRF52811 with a LoRa modem. The application handles two scenarios, Case 1 and Case 2, both leveraging Zephyr and the system off mode for ultra-low power consumption. However, I have observed unexpected behavior regarding current consumption after GPIO interrupts in Case 1.


    Observed Behavior:

    • Case 1: After waking up the main thread via GPIO interrupt and entering system-off mode, the current consumption is 300–450 µA, significantly higher than expected.
    • Case 2: Directly entering system-off mode results in current consumption of ~2.5 µA, which is expected.

    There is a significant difference in current consumption between these two cases in system-off mode.


    Application Details:

    Hardware Setup:

    • nRF52811 microcontroller.
    • LoRa modem connected to the nRF52811.

    Test Code:

    #include "inc/util.h"
    #include "inc/du_radio_hal.h"
    #include <zephyr/kernel.h>
    
    #define CASE 2
    
    int main()
    {
            // Configure LEDs
            led_init();
            // Indicate booting by LEDs
            led_on_boot();
            // Initialize the radio device
            du_radio_init();
            // Initialize GPIO pins and interrupts
            pins_init();
    
            k_sleep(K_SECONDS(5));
    
    #if CASE == 1
            shutdown_cpu(DU_SLEEP_STANDBY);
    
            while (true)
            {
                    shutdown_cpu(DU_SLEEP_SHUTDOWN);
            }
    #elif CASE == 2
            while (true)
            {
                    shutdown_cpu(DU_SLEEP_SHUTDOWN);
            }
    
    #endif
    }
    

    Test Cases:

    Case 1: GPIO Wakeup Path

    1. The main thread sleeps and is configured to wake up via GPIO interrupt.
    2. Upon a button press, the system wakes up and the main thread executes.
    3. After waking, the system is placed into system-off mode using shutdown_cpu(DU_SLEEP_SHUTDOWN).

    Result: Current consumption in system-off mode is ~300–450 µA.

    Case 2: Direct Shutdown

    1. The application directly enters system-off mode without waking the main thread.

    Result: Current consumption in system-off mode is ~2.5 µA.


    Attachments:

    1. Test Code: test-code.zip
    2. Case 1 Current Consumption Measurements: case-1-current.zip
    3. Case 2 Current Consumption Measurements: case-2-current.zip

    Expected Behavior:

    The current consumption in system-off mode for Case 1 should be consistent with Case 2, i.e., ~2.5 µA.


    Possible Cause and Questions:

    1. Could the GPIO wakeup interrupt be leaving peripherals or components (e.g., clocks, peripherals, or the LoRa modem) enabled, causing higher current consumption?
    2. Are there any additional steps required to properly power down the device after a GPIO interrupt?
    3. Is there an internal state in the nRF52811 that might differ between direct shutdown and wake-up via GPIO?

    Request for Help:

    • Guidance on why the current consumption differs between the two cases.
    • Suggestions for debugging and ensuring all peripherals are properly powered down in Case 1.
    • Any specific configurations or settings required in Zephyr to handle GPIO wakeup followed by system-off mode efficiently.




      I hope this will provide some more insights about this issue.
Children
Related