[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Problem with timer0 overflow interrupt in c language.
Re: [avr-gcc-list] Problem with timer0 overflow interrupt in c language..
Fri, 7 Dec 2007 10:23:45 -0600
On Fri, Dec 07, 2007 at 08:55:16AM +0200, Julius Luukko wrote:
> Or let the compiler handle reading from PIN and writing to PORT by using:
> PORTB ^= 0xff;
The compiler won't read PINB using the above.
In general on AVR when one reads PORTB one reads the output latchs, in
other words the last value written. On other CPU's this same action may
read the input buffers. AVR provids PIN ports for specifically reading
the state of the external pins.
Using -O1 the above exclusive-or-equals generates exactly the same code
as the OP first wrote:
PORTB = ~PORTB;
3ee: 85 b1 in r24, 0x05 ; 5
3f0: 80 95 com r24
3f2: 85 b9 out 0x05, r24 ; 5
PORTB ^= 0xff;
3f4: 85 b1 in r24, 0x05 ; 5
3f6: 80 95 com r24
3f8: 85 b9 out 0x05, r24 ; 5
David Kelly N4HHE, address@hidden
Whom computers would destroy, they must first drive mad.