Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner