Clkset
computer guy
Posts: 1,113
Hello,
I want to slow the propellers internal clock down during idle times (to save battery power).
I currently have these settings:
Can someone give me a good example of values to put into the CLKSET function to put it into an "idle" state.
In this state all I need to do is wake up every 30 seconds for 2 seconds or so. FDS will also be looking for serial data at 115,200kbps.
So the clock speed needs to be fast enough to receive at 115,200kbps. Apart from that as long as I can WAITCNT for 30 seconds, it should be ok.
Basically the program wakes up every 30 seconds, reads a sensor using RCTIME, sends the value over Bluetooth and then goes back to sleep.
Thank you
I want to slow the propellers internal clock down during idle times (to save battery power).
I currently have these settings:
_clkmode = xtal1 + pll16x _xinfreq = 5_000_000
Can someone give me a good example of values to put into the CLKSET function to put it into an "idle" state.
In this state all I need to do is wake up every 30 seconds for 2 seconds or so. FDS will also be looking for serial data at 115,200kbps.
So the clock speed needs to be fast enough to receive at 115,200kbps. Apart from that as long as I can WAITCNT for 30 seconds, it should be ok.
Basically the program wakes up every 30 seconds, reads a sensor using RCTIME, sends the value over Bluetooth and then goes back to sleep.
Thank you
Comments
Here are a couple of the constants used above.
The "Speed" object is the program "Clock.spin" from the Prop Tool's library.
I left a bunch of extra house keeping statements in the method.
Instead of a waitpne you could use a waitcnt with the appropriate wait amount with the Prop running in RCSLOW mode.
All other cogs are stopped before putting the Prop in RCSLOW mode. When the Prop wakes back up all the other cogs have to be restarted.
These methods take into account enabling and disabling of XTAL and PLL, to correctly save you power. It also has the right timing between clkset operations.
If the timing doesn't need to be exactly 30 seconds, it would be best to put the Prop into _rcslow_prop (20kHz), then "wake it up" using _rc_to_fast_prop (80MHz). If the 30 seconds need to be precise/accurate, you will have to continually use the crystal, so the slowest you can go is 5MHz. So then you would have to use _slow_prop and _slow_to_fast_prop.
If your scheme does allow a drop to micro-power RCslow, the slow phase code should be absolute minimum and in-line, not levels of methods removed. It will usually consist of a WAIT for a pin or a count and then (in line) perhaps a simple conditional test and loop, or an immediate switchover to 12MHz RCfast, with or without the crystal oscillator enabled to allow it to get up to speed while the program executes non-time-critical tasks.
thanks for posting your code examples and ideas on this. It's been very helpful today.