Achieveing low power with FreeRTOS and K22F

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Achieveing low power with FreeRTOS and K22F

1,156 Views
davepfaltzgraff
Senior Contributor I

I have an application based on the K22F that uses FreeRTOS. Now, I need to get it to operate in low power mode. I've added the code to use the LPTimer in Tickless mode as per the demo application, but I find that the processor never goes idle as the debug console is always polling for input. It seems that the debug console is the biggest culprit as all my other code is interrupt driven and uses the semaphores and queue capabilities provided by FreeRTOS.

 

This leads to some questions:

 

1. Is there a variant of the debug console that utilizes the FreeRTOS interrupt capabilities rather than polling?

 

2. Is there an on-line resource that would provide pointers to getting the application to run on as low power as possible?

 

3. Where is the idle task for FreeRTOS defined?

 

Thanks

Labels (1)
0 Kudos
6 Replies

479 Views
davepfaltzgraff
Senior Contributor I

Hi Richard,

Thanks for the link. A quick survey showed a lot of possibilities.

Later...

0 Kudos

479 Views
FreeRTOS_org
Contributor IV

That last part is necessarily device specific because you have to look at what clocks and power saving modes are available on your particular device.  There are several examples for other devices in the FreeRTOS download, both for up-counting clocks and down-counting clocks that you can use as references.  Also try entering "tickless" in the search box on this site as I think you may find something close to what you need there.

479 Views
FreeRTOS_org
Contributor IV

It is not clear to me which method you are using to place the processor into idle mode.  Are you just wanting to add a wfi into the idle task?  If so, so you can define an idle task hook function and do it there.

A little more sophisticated would be to use a basic tickless idle mode, or to maximise power consumption and use sleep modes that turn the system clocks off, a target specific tickless idle mode that uses a slow clock that remains running even when everything else is sleeping.

0 Kudos

479 Views
davepfaltzgraff
Senior Contributor I

Hi Richard,

This is actually a carry through from an earlier separate e-mail thread, but let me outline what I want to do. I'm running on a K22F processor and just want to go into the lowest power mode while retaining the ability to respond to interrupts in a timely manner. Right now, my portion of the code is set up so that nothing happens unless an interrupt initiates a response. My system is consuming around 30mA of current which is way above my budget. I think there are two things going on.

1. Whenever I break into the execution, I find that the code is in a loop waiting for input to the debug console. As I step, I see that the code is polling and it seems to me that FreeRTOS sees this as an active task. So, the first portion of my effort is to rewrite the interface to the serial port to use the FreeRTOS routines. (I'm working on that now.)

2. Once I have it so that there are essentially no active tasks to run, I want to get the processor to drop into a sleep mode. I presume this is where the clock to the processor is stopped but the clock to the peripherals is still running so that an external interrupt would get the processor going again.

I hope I am using the right terms... Since I'm new to using the ARM architecture in a low power mode, this is a learning exercise for me.

Thanks

0 Kudos

479 Views
FreeRTOS_org
Contributor IV

Yes - if you are polling - then the task is running.  The most benefit from using an OS comes when you remove all polling by making everything event driven.  If the debug console is a UART this should not be too strenuous.  Have your task block on an event, and have the ISR signal the event.  The most efficient way of doing this would be to use a direct to task notification - look at the example code on this page.

Once you are sure all your tasks are blocked waiting for events, rather than consuming CPU cycles for no reason, the simplest first step will be to set configUSE_TICKLESS_IDLE to 1 in FreeRTOSConfig.h.  That gives you the most gain for the least effort - but keeps the systick clock running, so means you cannot enter a sleep mode that turns that off.  You can define pre and post sleep macros to do things like turn peripherals off, etc., but the clock needs to keep going.  After that, if you want to go ultra low power (I'm not sure what features that chip has) then you need to write your own "suppress ticks and sleep" function that uses a clock other than the systick - allowing you to turn the systick off.  There are examples of the FreeRTOS download, see the links in my previous post.

0 Kudos

479 Views
davepfaltzgraff
Senior Contributor I

Hi Richard,

On the first suggestion, that's what I was doing in part 1. I was able to complete that yesterday. This morning, I was able to egt to the point where I defined configUSE_TICKLESS_IDLE to 1 and did see the corresponding power savings. In reading the article on the FreeRTOS web site on "Low Power Support", it seems that I could carry this one step further by defining it to 2. However, when I do that, I get a compile time error as the portSUPPRESS_TICKS_AND_SLEEP macro has not been written. Has anyone in the Kinetis community done that? (Or working on it?)  I could use the extra margin in power savings, but right now have to get on with writing my application.

Thanks for your help.

0 Kudos