Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

How to exit low power mode with IDLE Hook?

Posted by marting2015 on February 16, 2015

I have enabled the IDLE hook and using it to put the processor into a low power mode. How do I exit low power mode? It would seem I would need another hook that tells me when a non-IDLE task is scheduled... I am also using tickles mode.

I can see that the scheduler is turned off (SUSPEND) and there is a call to RESUME when FreeRTOS exits sleep mode (see portTASK_FUNCTION()). One solution could be to trigger a special (highest priority) task that restores the CPU (exit low power) before any of the other tasks run, which I guess could be done with a semaphore to a high priority task, and GIVE the semaphore when xTaskResumeAll() is called. However I don't want to touch FreeRTOS functions, so I don't think this is the right approach.

I tried putting my exitlowpower code in vPortSuppressTicksAndSleep() but the target crashes hard... I suspect because my exitlowpower uses FreeRTOS APIs, and vPortSuppressTicksAndSleep() is probably running in special (interrupt?) context where I can't call those APIs. Because I am using tickles mode, my openOCD GDB connection won't work to debug it further.


How to exit low power mode with IDLE Hook?

Posted by rtel on February 16, 2015

As we were just discussing in this thread: http://sourceforge.net/p/freertos/discussion/382005/thread/e717bb2f/#d81e if you are using tickles idle then you should >not< be doing any of this stuff in the idle hook - all you should be doing is defining the pre and post sleep macros if that is desirable to do something chip specific before and after the sleep respectively.

You cannot use another hook, or another task, because when the CPU is sleeping nothing is running (so the task you want to use to wake up is not running so can't wake you up).

The tickless idle mode takes care of all this for you. It will wake up at the right time, or when an interrupt occurs.

Regards.


How to exit low power mode with IDLE Hook?

Posted by marting2015 on February 17, 2015

I thought this was a different enough topic to start a new thread. I think my question is slightly different...

Lets say that I have an LDO that I want to turn off when that component is not being used, and I know its not being used when the IDLE task is running. But when any other task is running, the component may be used. So in the IDLE hook I would turn off the component. But when do I turn it on?

Based on your answer above, and from the other thread, I can use the pre and post sleep macros to turn OFF/ON the LDO. That makes sense. And works in tickles mode. In tick mode, though, those macros aren't called.

If I wanted to use the IDLE hook to turn off the LDO, if there a mechanism to turn on the LDO when the IDLE task is pre-empted to run (any) other task?


How to exit low power mode with IDLE Hook?

Posted by rtel on February 17, 2015

I think you would have to do that from a trace macro - you could use traceTASKSWITCHEDOUT( x ). If x is not the idle task then do whatever you need to do. Note the macro might be called from an interrupt though, so whatever you do will have to be fast.

If INCLUDExTaskGetIdleTaskHandle() is set to 1 in FreeRTOSConfig.h then inside the traceTASKSWITCHED_OUT() macro the handle of the idle task is held in a variable called xIdleTaskHandle.

To ensure future proofing the code though you would be better off calling xTaskGetIdleTaskHandle() yourself rather than relying on the name of the variable not changing in future FreeRTOS versions.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists