View previous topic :: View next topic |
Author |
Message |
Kimmeridgien
Joined: 22 Feb 2007 Posts: 89 Location: Stockholm
|
Posted: Wed Nov 26, 2014 9:23 pm Post subject: ATmega168xx RTC and sleep mode question |
|
|
Hi,
Here's a tough nut to c r a c k (apparently ***** is an inappropriate word):
Basically, I have two choices:
1. Use timer2 which can be used with the "extended standby" sleep mode. The drawback is that it is an 8-bit counter, so with for example a 7.3728MHz crystal I can at best get a 30Hz RTC frequency with a 1024 prescaler and 239 top value. Also, this sleep mode has a 6 cycle wake-up period.
2. Use timer1 which can only be used with the "idle" and "ADC noise reduction" sleep modes. It is a 16-bit counter, so I can get a 1Hz RTC frequency with for example a 19.6608Hz crystal at 1024 prescaler and 19199 top value.
I am using an external crystal, so I can't use an additional 32768 Hz RTC crystal with the ATmega168xx series.
The datasheets have graphs for power consumption per clock frequency, and although the higher clock consumes more power, it's actually a little more efficient per MHz at 20MHz than at lower frequencies. Still, idle current at 20MHz is 3 times that at 7.3728MHz. Similarly, non-sleep consumes roughly 4 times as much as idle regardless of frequency for this frequency range. Getting the job done quicker and then idling eliminates some of the saving from lower clock frequency.
Furthermore, only waking up from sleep once per second compared to 30 times per seconds should counter this effect. Additionally, higher clock frequency might add a little to the user experience.
I'm sorry that I can't formulate this as a proper question, but I would value your opinion/experience on this. How should I decide?
Some data from the PA datasheet:
5V, first is 20MHz, second is 7.3728MHz
Non-sleep:
9.1mA 0.455mA/MHz
3.7mA 0.502mA/MHz
Idle:
2.2mA 0.11mA/MHz
0.8mA 0.114mA/MHz
Standby extrapolation:
500uA
200uA
Thanks in advance.
Cheers
Niclas
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
Dave
Joined: 05 Feb 2005 Posts: 314 Location: OR
|
Posted: Thu Nov 27, 2014 1:49 am Post subject: |
|
|
Niclas,
I assume you are using the 7.3728MHz so the baud rates work out right.
I sometimes run the internal osc. at 7.3728MHz for that reason.
If you used the internal osc. for the main clock you could then use an external 32768Hz for timer2 and have 1 second interrupts.
You would need to calibrate oscal to make internal osc runs at 7.3728MHz.
Dave |
|
Back to top |
|
|
Kimmeridgien
Joined: 22 Feb 2007 Posts: 89 Location: Stockholm
|
Posted: Thu Nov 27, 2014 11:50 am Post subject: |
|
|
Hi Dave,
Thanks for your reply. Your suggestion is good and would indeed solve much of the problem I described.
There are two reasons why I can't go that way:
After a closer investigation I must use 6MHz for one of the designs and as high as possible for another, which for practical reasons turns out to be 20MHz. (This is due to PWM frequency requirements and available prescaler values. In fact only a single 15625 baud rate is then possible.)
The second reason is that the calibrated RC oscillator is a little too temperature dependent (about 2.2% between 25degC and 85degC at 5V for 48PA). This is more than the recommended USART deviation.
Still, for future designs it would be nice to get a clearer picture of how much more does indeed get saved when going from idle to extended standby. For example the ATmega324 series has different pins for main crystal and RTC crystal and the ATxmega can be PLLed from a 32kHz crystal to a high frequency main clock.
Cheers
Niclas |
|
Back to top |
|
|
Kimmeridgien
Joined: 22 Feb 2007 Posts: 89 Location: Stockholm
|
Posted: Fri Nov 28, 2014 11:49 pm Post subject: |
|
|
BTW, Atmel is just now releasing the ATmega168PB series with improved calibration and stability of the internal RC oscillator. |
|
Back to top |
|
|
|