FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2014 Threads] dis/enable peripherals on idle/wakePosted 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/wakePosted 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/wakePosted 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|