[En-Nut-Discussion] power optimizations in idle thread
Mustafa Yuecel
yuecel at tik.ee.ethz.ch
Tue Apr 10 16:59:08 CEST 2007
Hi,
In order to reduce the current consumption on our BTnodes I would like
the commit the following changes on arch/avr/os/nutinit.c to CVS.
1. NutThreadSetSleepMode returns the old value (like NutThreadSetPriority).
2. disable ADC and buskeeper before entering sleep mode and re-enable
these after wakeup:
if (idle_sleep_mode != SLEEP_MODE_NONE) {
sleep_mode = AVR_SLEEP_CTRL_REG & _SLEEP_MODE_MASK;
set_sleep_mode(idle_sleep_mode);
cbi(ADCSR, ADEN); // disable ADC
cbi(XMCRB, XMBK); // disable buskeeper
/* Note: avr-libc has a sleep_mode() function, but it's broken for
AT90CAN128 with avr-libc version earlier than 1.2 */
AVR_SLEEP_CTRL_REG |= _BV(SE);
__asm__ __volatile__ ("sleep" "\n\t" :: );
AVR_SLEEP_CTRL_REG &= ~_BV(SE);
sbi(XMCRB, XMBK); // re-enable buskeeper
sbi(ADCSR, ADEN); // re-enable ADC
set_sleep_mode(sleep_mode);
}
1. is a quick change, but 2. throws some problems up:
- the ADC may be used as wakeup source for SLEEP_MODE_IDLE and
SLEEP_MODE_ADC, so it should not be disabled in any case. Either we use
a define option at compile time or we set up the policy that the ADC
remains only enabled in SLEEP_MODE_ADC.
- the buskeeper is only useful/enabled if external RAM is available.
Maybe we can use here '#ifdef NUTXMEM_SIZE'?
Any comments?
I proposed these changes (among with others) on
http://www.btnode.ethz.ch/Projects/JAWS-DSNPowerdownFeature. All the
modifications decreases the current consumption of around 0.25 and 0.35 mA.
Best,
Musti
More information about the En-Nut-Discussion
mailing list