[Top][All Lists]

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

Re: [avr-libc-dev] RFC: avr/bits.h

From: Joerg Wunsch
Subject: Re: [avr-libc-dev] RFC: avr/bits.h
Date: Tue, 1 Mar 2005 22:18:17 +0100
User-agent: Mutt/

As Nicolas Schodet wrote:

> The interrupt flag bit is read as 1, and writen at 1, this clear the
> interrupt bit! A warning could be added to the manual.

There's a paragraph in the FAQ that explains why interrupt flags are
written as 1 (in short: so that you *don't* need to use read-modify-
write operations but can write your 1-bit directly).  If you want to
improve on this description, please tell us so.  Obviously, that will
only work for IO registers that are dedicated for interrupt flag bits,
so in the TWCR case, you have to keep a copy of the remaining bits
(that are not related to the interrupt) elsewhere.

> Another question about bit manipulation: what is the best way to
> read 4 bytes into a double word?

IIRC, a union works best.

Btw., be careful with descriptions like `double word'.  Some
architectures would consider a 32-bit number a `word'.  Better always
make it explicit which number of bits you're referring to.  In C code,
I'd strongly promote the use of C99 <stdint.h> names as they are now
(finally) standardized.

> This could also be included in the bit manipulation header.

Better not, as it is completely unrelated to *bits*.  That doesn't
mean any such interface should be banned from avr-libc, but please
don't try to hijack header files for things they have not originally
been intented for.

cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

reply via email to

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