From: eeboy on
I have a system that needs to spend the majority of its time in a sleep
mode (using internal 30kHz oscillator), wake to respond to some interrupts
(either still running at 30kHz or 6MHz external crystal) and occasionally
perform some high speed tasks (using the 6MHz external with a PLL --->
50MHz). I've neglected my power management to this point and now I am at
the tail end of the project looking to comeback through and add clock
management.

I am having a problem coming up with an elegant way to manage this. My
current scheme (which I have yet to implement because I feel it could be
done cleaner) is like so:

struct{
char * pcFlag;
char cState;
}g_sPowerMangement[10];

char g_cCurrentClock;

char systemPowerChange(char * pcFlag,char cState){

//Set flag = 1
//Add request to g_sPowerManagement
//If request is greater than current speed, change clock speed and all
peripherals dependant upon it

}

void systemPowerMangement(){

//Loop through g_sPowerManagement to see if any pcFlags are cleared,
if cleared remove from g_sPowerManagement
//If no more requests for a current clock speed, fall back to next
lowest and change all peripherals dependant upon it
//If no items remain in g_sPowerManagement go to sleep

}


Basically the module that requires the extra speed will create a global
flag and call the power change function with a pointer to the flag and the
desired speed. The clock will then be adjusted. The power management
function will be called repeatedly from an infinite loop in main. It
ensures that the system is running at the lowest possible clock based on
the requests held within the power management structure. When no more
requests exist in the structure the system goes to sleep.

For the most part I think this is decent except in a module that has many
exit points where I could potentially miss the clearing of the flag
(keeping the system at the requested speed forever).

Does this sound like a reasonable approach? How do others handle this?


---------------------------------------
Posted through http://www.EmbeddedRelated.com
From: RockyG on
>I have a system that needs to spend the majority of its time in a sleep
>mode (using internal 30kHz oscillator), wake to respond to some
interrupts
>(either still running at 30kHz or 6MHz external crystal) and occasionally
>perform some high speed tasks (using the 6MHz external with a PLL --->
>50MHz). I've neglected my power management to this point and now I am at
>the tail end of the project looking to comeback through and add clock
>management.
>

<Snip>

>Does this sound like a reasonable approach? How do others handle this?

We found that the most power-effective way to handle sleep with periodic
wakeup was to use the clock at full speed so as to get back to sleep ASAP.
The power used was quite high even at the slow clock and therefore to
quicker the jobs were done the better.

---------------------------------------
Posted through http://www.EmbeddedRelated.com