Sleep transition from 1. 9V and 2 MHz to 3V and 32 MHz

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using an Xmega256a3 that is set at 1.9 V and 2 Mhz when sleeping to reduce current consumption. When awake it is set at 3 V and 32 Mhz. I had not been checking or delaying between setting a pin to change the voltage from 1.9 - 3 V and setting 32 Mhz for I "assumed" it wouldn't come up until it was stable. What happens is if I leave the voltage at 1.9 V the 32 MHz gets set as the system clock but is not stable and thus will eventually cause problems that induce a watchdog reset.

Here is my test:

    // previously set to 2 MHz and 1.9V
    cpu_sleep();
    printf("\nSetting Clock 32 MHz");
    setClock32MHz();
    printf("\nClock set 32 MHz");

Output:

Setting Clock 32 MHz
Clock set 32MHz
-code runs for a bit
-oscillator instabilities cause watchdog reset


void setClock32MHz(void)
{
	CCPWrite1(&OSC.CTRL, OSC_RC32MEN_bm); // Enable 32 MHz internal oscillator
	CCPWrite1(&CLK.PSCTRL, CLK_PSADIV_1_gc); // Prescalor to divide clock
	do { } while((OSC.STATUS & OSC_RC32MRDY_bm) == 0); // wait for oscillator ready
	CCPWrite1(&CLK.CTRL, CLK_SCLKSEL_RC32M_gc); // select sysclock 32MHz osc
	OSC.CTRL &= ~(OSC_RC2MEN_bm);	 // Disable 2 MHz Clock
	OSC.DFLLCTRL = OSC_RC32MCREF_bm; // Enable Auto Calibration
}

I would have thought the oscillator ready would have kept it spinning until the oscillator was stable (voltage came up to 2.7 V - cutoff for stable 32 MHz oscillator). Since this doesn't happen is there anything I can do to guarantee 32 MHz is "stable" before I make it the sysclock?

My thoughts were adding a time delay or using the ADC but neither seems a very clean way to guarantee stability.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is not guaranteed that clock may not be stable at 32 MHz at 1.9 V.
May be than clock will work 32 MHz at 1.9 V, but CPU will not work at this conditions.
Use of ADC to measure Vcc against (internal) reference is much more clean way to guarantee stability.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the response.

The challenge with using the ADC (other than the humor of putting ADC and stable in the same sentence when dealing with an Xmega) is the time/current it would take to turn it on and do the measurement. Not a hit I want to take every time I wake from sleep.

I will try turn up the voltage after I set the system clock to 32 MHz and see what happens. Maybe it is unnecessary to worry about the voltage before switching the clock?

Last Edited: Tue. Jun 18, 2013 - 07:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Playing devil's advocate, what sleep mode is being used? The charts indicate insignificant power saving in power-down and power-save modes. Idle or standby?

If you have time to sleep, is there a need for the 32MHz? Or can you just run "low and slow" like a Texas brisket barbeque smoker all the time?

I'm curious about how you change the supply V.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We run in power save so the RTC can keep running and we get significant current savings (from mA to uA). That savings increases significantly when you switch to 1.9 (1.8 V in the table) and 2 MHz. Are results are very similar to what is shown in Table 34-1 of the datasheet.

We used to run "low and slow" and it worked well but we are now trying to switch so that we are awake for less time and sleeping more. Hoping to save a little more power.

We change supply voltage using a TI boost converter (TPS6120) that allows us to step between 1.9 and 3 V using one of the xmega pins.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

photonthunder wrote:
we are now trying to switch so that we are awake for less time and sleeping more. Hoping to save a little more power.

You will not gain power save this way.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

maksim wrote:
photonthunder wrote:
we are now trying to switch so that we are awake for less time and sleeping more. Hoping to save a little more power.

You will not gain power save this way.

Well, what AVR model in particular are we working with?

Let's say I have AVR work that needs to be done each second, and I can get all my work done, barely, in one second running at [pick frequency] at 128kHz.

Or, I can run at 8MHz, get all my work done in 16ms, and go to deep sleep for 98% of the time.

So, you are saying that Active consumption at 128kHz is less than Active at 8MHz for 2% of the time, and Power-Down with a wakeup source enabled for 98% of the time?

Looking at the Xmega A3U datasheet, let's see what comes out. As Xmegas are pretty efficient, Active consumption is low. From the graph, let's say 300uA at 128kHz and 3.0V.

8MHz Active -- ~4mA
8MHz Standby, Power-Save, Power-Down are all in the low uA range, depending on wakeup source and etc. Let's go on the high side and say 10uA. Idle mode maybe 2x or 3x more.

2% of 4000uA is 80uA, plus the 10uA during the sleep, gives a draw of 90uA by going-fast-then-sleeping.

So, my quick analysis seems to indicate that go-fast-then-sleep takes 1/3 of the power as plodding along. The hare wins, right?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

So, my quick analysis seems to indicate that go-fast-then-sleep takes 1/3 of the power as plodding along.

In your case may be yes. But in this case of the topic-starter:

2 MHz 1.8 V - 0.613 mA
32 MHz 3 V - 15.7 mA

At 32 MHz it will compute 16 times faster, but power current will be 15.7/0.613 > 16 times more.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your posts have me pondering the value of flipping the voltage down. If we run at 32 MHz and 3 V how much current do we save switching to 2MHz/1.9 V for power save sleep. Initial results, as indicated by your post theusch, we don't see much benefit of making the voltage switch while sleeping.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

2 MHz 1.8 V - 0.613 mA
32 MHz 3 V - 15.7 mA

At 32 MHz it will compute 16 times faster, but power current will be 15.7/0.613 > 16 times more.


You compared apples to oranges--the supply voltage changed.

My analysis just compared running at a constant voltage, and slow clock (128kHz) continually vs. fast clock (8MHz) and sleep.

Indeed, there may be combinations where the analysis flips the other way. My summary based on AVR8 battery-powered apps:

-- Traditionally with AVR8 (e.g. Mega48), the lowest power with periodic wakeup was the watchdog interrupt. With newer models, timer2 with watch crystal can match those numbers and give more accurate timing. The results are usually quite close.
-- Before Mega48-era (e.g. Mega8), it was difficult if not impossible to get down to low uA with AVR8; never bothered to try.
-- In my complete (generally) industrial apps, the complete circuit usually has a few uA here-and-there. So, with a decent-sized battery/pack I usually quit once the whole app was down to <10uA sleeping. With many battery types, this would be less than the internal leakage/shelf-life anyway.
-- With modern battery chemistries and certain apps like a "mote", one might certainly be running around looking for nA. I've just never had that type of app.
-- Some of my battery apps have big power suckers such as periodic RF comms or sensors such as ultrasonic. If they take periodic readings in general the power budget is overwhelmed by the e.g. 30mA RF transmitter current for some milliseconds, vs. the AVR active current for calculations, and the relatively miniscule sleep current.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

You compared apples to oranges--the supply voltage changed.

The change of the supply voltage is important.
Every single switching of CMOS logic get less energy if done at lower voltage.
The same calculation require the same number of logic switchings. If they done with lower voltage, the total energy dissipated is smaller.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I understand that. But you can't just say

Quote:

At 32 MHz it will compute 16 times faster, but power current will be 15.7/0.613 > 16 times more.

out of context. Of course that is true, with different voltages. But for the "power budget" you have to make an analysis such as what I did roughly above. (In a real app, I use a spreadsheet and measurements of current draw and time at each draw level.)

From what I've seen here I don't see a significant savings. Switching supply levels isn't free, is it? And, the existence of the thread itself would seem to indicate that it makes things more complex.

But the thorough analysis may indeed reveal that the approach ends up to be a power saver.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.