> I'm concerned that because you're doing this in C, the compiler won't 
> generate efficient >enough code

There was a single unnecessary reload from the compiler generated code.
This assembly language file (bodsleep.S) does work on the Tiny88:

;20090213 Disable Brown Out Detect during Sleep.  Has critical cycle
timing. IRQs must be off.

#include <avr/io.h>

        .section .text

        .global bod_sleep
bod_sleep:
        IN      R24,_SFR_IO_ADDR(MCUCR)    ; Load MCUCR to R24
        ORI     R24,(_BV(BODS)|_BV(BODSE)) ; Set Brown Out Disable
during Sleep and enable the bit change
        OUT     _SFR_IO_ADDR(MCUCR),R24    ; Store MCUCR
        ANDI    R24,~(_BV(BODSE))          ; Clear BODSE
        OUT     _SFR_IO_ADDR(MCUCR),R24    ; Store MCUCR with BODSE cleared
        SEI                                ; Enable Interrupts
        SLEEP                              ; Go to sleep
        RET

> And, why are you using __interrupt_enable() instead of sei()? Are you trying 
> to have this >work under AVR GCC and IAR too?

I try to write all of my code in tool neutral format, more portable
that way.  All of my projects include "compiler.h" that does The Right
Thing depending on what compiler might be in use (IAR, GCC, Imagecraft
etc).  I have moved all of my projects except one, Tiny2313 with zero
bytes free in IAR, to GCC.


_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to