View Full Version : Is there a way to put the Propeller to "sleep" ?
11-10-2011, 01:26 AM
One of my Menu options turns off a display to conserve power. I use a rotary encoder with a center push button to select it. By pushing the button or rotating the encoder brings the display back on.
I assume I can use cogstop to stop all but the main menu method but is there a command to put it in low power mode? If so is it much of a savings in power? Any examples welcome.
11-10-2011, 02:24 AM
If you use the pushbutton only to wakeup the prop, you can place the cog in a waitpxx instruction and that will reduce the current in that cog. If all others are stopped, then there is little current drawn. You can further reduce current by slowing the clock frequency or using the internal rc oscillator but remember to allow the clock to stabilise before you continue. There is a writeup in the datasheet IIRC.
11-10-2011, 02:43 AM
So a couple questions- can you bring it out of the waitpxx instruction and wake it up? Can you change the clock frequency on the fly from 80Mhz to RC speed and then go back again when you wake it up?
Phil Pilgrim (PhiPi)
11-10-2011, 03:54 AM
Can you change the clock frequency on the fly from 80Mhz to RC speed and then go back again when you wake it up?
Yes. Change it to RC_SLOW for minimum current draw -- especially if you don't want to stop the other cogs -- then back to the crystal mode upon wake-up. Refer to either the manual or datasheet (can't remember which) for the correct sequence of steps to do it.
11-10-2011, 04:38 AM
You could also use the clock object (included in the PropTool library) which - although slightly broken (rev 1.1) - does all the difficult bits for you.
Changing clock rates in program
11-10-2011, 05:00 AM
There is nothing too complicated about it. You will tie the waitpxx instruction to the button input in the low power state and the propeller will continuously scan that button at about 20kHz until the button changes state. The program then moves on to the instructions that push the operating frequency up, and that can happen in two steps, one running at 12MHz for code that does not have critical timing, and then onto the crystal+PLL for the good timing. Here is a little demo of a cycle that runs around from low power (3 ľA per cog) to high power operation for a second, every time a button is pressed.
' set all i/o to minimal power states
' flush all tx buffers.
clk_slowRC ' slow to 20 kHz
waitpne(ina<<27, |<27, 0] ' get state of pin 27 then wait for it to change to opposite state
clk_fastRC_xtal_On ' turn on xtal osc, but now operating on RCfast at ~12 MHz
' now Prop is operating at 12 MHz and can execute code that has non-critical timing.
waitcnt(clkfreq/100 + cnt) ' this 10 millisecond delay allows xtal oscillator to become stable.
clk_xtal(80) ' switch over from RCfast to xtal to operate at 80 MHz
' within 75 microseconds, Prop is operating at 80MHz and can execute time-critical code
waitcnt(clkfreq + cnt) ' this is one second for the demo, to repeat, back to low power
clkset(%0_00_00_001, 20_000) ' drop to RCSLOW at ~20 KHz
clkset(0_00_00_000, 12_000_000) ' xtal oscillator off, operating on RCfast at ~12MHz
clkset(%0_11_01_000, 12_000_000) ' xtal osc & pll on, xtal1 drive is on, still operating on RCfast
clkset(%0_11_01_000 | >|(MHz/5)+2, MHz*1_000_000) ' switch xtal+pll, MHz must be 5, 10, 20, 40 or 80