[En-Nut-Discussion] power optimizations in idle thread

Henrik Maier hmlists at focus-sw.com
Thu Apr 12 01:53:34 CEST 2007


Why not saving the ADC bit and buskeeper bits and set it to the previous
state after wake-up?

Henrik

> -----Original Message-----
> From: Mustafa Yuecel [mailto:yuecel at tik.ee.ethz.ch]
> Sent: Wednesday, 11 April 2007 12:59 AM
> To: en-nut-discussion at egnite.de
> Subject: [En-Nut-Discussion] power optimizations in idle thread
> 
> 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
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
> 





More information about the En-Nut-Discussion mailing list