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

dis/enable peripherals on idle/wake

Posted by gmenhennitt on March 18, 2014

We run our application under the MSP430X port of FreeRTOS 8.0.0 in tickless mode. When we are idle we want to disable some peripherals (I2C, UART, timers) to save power. That's relatively easy to do by adding code to vApplicationIdleHook(). However, we also need to do the opposite - wake up the peripherals when starting to execute a task (i.e. on becoming not idle). I added the following chunk of code at the bottom of xTaskIncrementTick().

~~~~~ if(xSwitchRequired) { extern void vApplicationNotIdleHook(); vApplicationNotIdleHook(); } ~~~~~

just before the line

~~~~~ return xSwitchRequired; } ~~~~~

Obviously, I add a new hook function vApplicationNotIdleHook() that does the enabling.

Could anybody please suggest whether this is going to achieve what I want? Is there a better way to do it?

Thanks for any help, Graham


dis/enable peripherals on idle/wake

Posted by davedoors on March 18, 2014

You can copy the tickless idle implementations for other chips http://www.freertos.org/low-power-tickless-rtos.html these have pre and post sleep macros to enable disabling then reenabling peripherals as you are trying to do.

If you want to do something in the idle hook then you could do something like

//Stop context switches so the idle task continues running after sleep vTaskSuspendAll();

//Turn off what needs turning off disablesomeperipherals();

//Call your sleep function waitforinterrupt();

//Reenable what needs reenabling enablesomeperipherals();

//Allow context switching again to yield xTaskResumeAll();

A hook in xTaskIncrementTick() is not going to execute until the next tick time and not at all if the clock used to create the tick is one of the things that you turn off before sleeping. Better to add a hook in the traceTASKSWITCHEDIN macros, or another trace macro that runs when you leave sleep. Another options would be to somehow signal a wake event from the interrupt that causes the wake.


dis/enable peripherals on idle/wake

Posted by gmenhennitt on March 19, 2014

Thanks for replying, Dave.

It looks like there are a few problems with my implementation. The foremost of these is that I wasn't actually running in tickless mode. I didn't realise that the MSP430 port doesn't implement this internally - I need to implement portSUPPRESSTICKSAND_SLEEP() myself (which I haven't). If/when I do that, I'll come back to this.

Thanks again, Graham


[ 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