avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-libc-dev] [RFC] Sleeping BOD API


From: Weddington, Eric
Subject: RE: [avr-libc-dev] [RFC] Sleeping BOD API
Date: Fri, 13 Feb 2009 07:24:22 -0700

 

> -----Original Message-----
> From: Bob Paddock [mailto:address@hidden 
> Sent: Friday, February 13, 2009 7:14 AM
> To: Weddington, Eric
> Cc: address@hidden
> Subject: Re: [avr-libc-dev] [RFC] Sleeping BOD API
> 
> > 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
>

Yes, and that is exactly what the inline assembly macros generates. That's why 
it has to be in inline assembly and not C.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]