On Mon, 31 Jan 2005 14:21:19 +0100, Svenn Dahlstrøm <svenn@symetrics.no> wrote: > I use ICCAVR and do it this way : > #define setbit(ADDRESS,BIT) ((ADDRESS) |= (1<<(BIT))) > #define clrbit(ADDRESS,BIT) ((ADDRESS) &= ~(1<<(BIT))) > #define chkbit(ADDRESS,BIT) ((ADDRESS) & (1<<(BIT))) > #define togglebit(ADDRESS,BIT) ((ADDRESS) ^= (1<<(BIT))) > and write code like this : > setbit(PORTA, 2); > togglebit(PORTB, 6); > clrbit(DDRC, 0); > And this can be used to set, clear, check or toggle one bit on any > register > or variable. > Svenn i like that. It's still not as clear to me as e.g. PORTB.1 but it is a very good solution already. thanks ST
Message
Re: [AVR-Chat] accessing bits (e.g. of ports)
2005-01-31 by Stefan Trethan