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

FreeRTOS Tickless Idle vs Tick Current Consumption

We have been comparing the current consumption of the nRF52 running FreeRTOS Tickless Idle versus a constant tick and using the idle task to sleep and the results are interesting, see below.

June 7th Edit: SDK 11, SoftDevice S132 2.0.0.0, Silicon is QFAABB (Rev C)

Tickless Idle:

  • Average current is 390uA

Tick with Idle Task:

  • Average current is 303uA

Both runs were identical with the floating point interrupt handler implemented as in this post devzone.nordicsemi.com/.../, same number tasks/execution profile, same tick rate, advertising off. The only difference is tick mode uses the idle task hook to put the processor to sleep.

Note the follow images were captured using our own Labview tool sampling at 8kHz. Ignore the bottom trace

Tickless Idle

image description

Tick with Idle Task image description

Parents
  • I also can't figure out what on earth would produce those results.

    What's running on the chip, do you have the softdevice loaded and active, is it doing anything at all? The tickless mode should be showing less than the other one, if it has nothing scheduled then it should put itself to sleep for seconds or minutes or basically forever.

    Are you sure you've got this test right? Because it really makes no sense at all.

Reply
  • I also can't figure out what on earth would produce those results.

    What's running on the chip, do you have the softdevice loaded and active, is it doing anything at all? The tickless mode should be showing less than the other one, if it has nothing scheduled then it should put itself to sleep for seconds or minutes or basically forever.

    Are you sure you've got this test right? Because it really makes no sense at all.

Children
  • RK,

    Yes, we are sure we have the test right the results can be easily duplicated. Yes, the softdevice is loaded and active but advertising is disabled.

    As I said above the only difference is tick mode is using the idle task and is calling sd_app_evt_wait() where as tickless idle has the idle task disabled and is using Nordic's implementation of vPortSuppressTicksAndSleep()

  • I can't think up a scenario which would give those results. OK so the SD is on but not even advertising, which means it generates no interrupts, it's really doing nothing at all. What code do you have running, just a few tasks which run on a timed basis or are there async bits to it, like external interrupts, SPI/TWI/UART data transfers etc? If it's just tasks running on timers, there's nothing to cause the chip to wake from sleep apart from the RTC tick, which runs (in the nordic port) at the RTOS tick rate.

    I wondered if the tick idle was being entered with interrupts turned off (BASEPRI set) but if that were the case, the RTC tick wouldn't wake you either, so that can't be it.

    I assume in the idle handler you're just calling sd_app_event_wait(). The reason it makes no sense is because the Nordic RTOS port also just calls sd_app_event_wait() in the tickless function ...

  • ... ( I hate that comments are limited) ... and the tickless function is called from the tick idle, just with the tick turned off and a compare interrupt turned on for a future time. So what you're doing sleeping in the idle handler is a superset of what tickless idle is doing, assuming you're even getting into tickless idle mode.

    The bottom trace, are those spikes at your RTC tick frequency, it's tempting to assume they are, but perhaps they are only every 10 or 20 ticks. How often are you doing work, every tick? Less than 2-3 ticks of idle, you're not actually getting into sleep mode.

    I've just spent bits of this week instrumenting things with SystemViewer, not only Nordic's FreeRTOS port but my own and also the softdevice itself. Would be interesting to apply that analysis, although having the debugger attached may mess up the results.

  • When doing tickless idle, the port sets up a wakeup timer to wake up in time for the next rtos event. In your case, you are just going to sleep and "hope" that something wakes you up at some point. It could just be that the rtos "oversleeps" because there is no mechanism to wake it up in time. So the question is: What is waking up the CPU after sleeping in idle task?

  • This is why I wanted to know what code is running, is it just timed code, at which point it will only task switch at a tick and I'd expect the bottom trace, or are there async events at which point I'd expect something like the top trace (assuming the async events call the yield function properly).

    The only case in the middle is where it's timed code but the expected timeout is always one tick, so tickless mode never actually goes tickless and runs around the idle loop. I suppose running tickless and also putting sd_app_evt_wait() in the idle loop might be an interesting test, if it then looks like the bottom trace that would indicate that tickless mode isn't ever really being entered.

    But yes knowing whether the code is just timer based or there's an async part to it would be rather helpful.

Related