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

Current consumption

Hi, 

I tried to monitor current consumption of my device. I used

 

sd_app_evt_wait();

and then used 

 // Wait for an event.
        __WFE();
        // Clear the internal event register.
        __SEV();
        __WFE();

I saw something like this

There are spikes on everywhere.

If I comment out sd_app_evt_wait(); or last __WFE(); it beacomes like that

I am using sdk 15.0.0, before this I was using sdk 14.2 and in 14.2 I was using sd_app_evt_wait function and there was no spikes. How can I fix it?

Thanks.

  • Hi

    Is this on a project you've migrated from the SDK v.14.2 to v.15.0? In that case, you should check out the migration guide to see that you did all of the required steps. It seems your device is not going to sleep properly, so you probably have some peripherals still running. Can you show me a snippet of your code on how you go to sleep/uninitialize your peripherals? Also, please keep in mind that you should refer to the compatibility matrix, to see that you use the correct SDK and Softdevice versions with the correct chip.

    Best regards,

    Simon

  • Hi, thank you for the reply. 

    No, those projects are totally different, sorry for misrepresentation. I talked about project on sdk 14.2 because when I use sd_app_evt_wait function there were no spikes. Now I am using same function in totally different project on sdk 15.0 and that spikes happened. Those two pictures from project on sdk 15.0, if I dont use sd_app_evt_wait() --> no spikes, if I use sd_app_evt_wait() --> spikes. 

    Also I tried this:

    __WFE();
    __SEV();
    __WFE(); 

    Like this it has spikes.

    __WFE();
    __SEV();
    //__WFE();

    If I comment out last __WFE(); it doesnt have spikes.

    This is my for in the main.c

    for (;;) 
      {
        if (isWorkingIntervalFunc() == true && oneShotFlag1 == false) {
          goToWorkingState();
          oneShotFlag1 = true;
          oneShotFlag2 = false;
        } else if (isWorkingIntervalFunc() == false && oneShotFlag2 == false) {
          oneShotFlag1 = false;
          oneShotFlag2 = true;
          goToSleepState();
    
        } else {
        }
        stateMachineRun();
    
        sd_app_evt_wait();
      }

    I dont know which peripheral is still running. I dont use uart, gpio, or others. I only do scannning and advertising.

    Thanks.

  • Ok, thank you for clarifying!

    What does the stateMachineRun() function do? If you're just scanning/advertising, I guess the radio is still active in your application. Also, do you use the SoftDevice in this application? If not, sd_app_evt_wait() and other sd function won't work, which might be why you're seeing these spikes.

    Best regards,

    Simon

  • I am using SoftDevice in the application.

    stateMachineRun() runs some tasks in order. It mostly runs task that scans for 2.4 seconds, then stops scanning, processes scan results, starts scanning again , starts advertising to advertise processed data(at the time which is not in scan window). It calls a bool function and that function always returns false until 2.4 seconds completed. I couldn't explain well, I hope you can understand me. Can calling a function continuously cause this?

  • Have you tried stepping through your code when debugging in order to see what exactly happens here? You should set a breakpoint just before stateMachineRun() and make sure sd_app_evt_wait() ever gets there, and what happens after. I have a suspicion, that either sd_app_evt_wait() is never reached, or that sd_app_evt_wait() doesn't last very long, as it really just waits for an event as well.

    Best regards,

    Simon

Related