avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Efficient I/O handling w. bitfields codegen problem


From: Russell Shaw
Subject: Re: [avr-gcc-list] Efficient I/O handling w. bitfields codegen problem
Date: Fri, 03 Dec 2004 11:25:10 +1100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040820 Debian/1.7.2-4

Albert Seward wrote:

On Thu, 2 Dec 2004, E. Weddington wrote:


Albert Seward wrote:


I have some problems with code generation from GCC 3.3. Read my question
in the main block.

/*
* bitfields.c
*
* GCC bitfields optimization test
*/

...


Hope anyone has the time to help me. I am really stuck.

The canonical way to change bits in ports in C language is not through
the use of bitfields. You need to learn to use the C language's bitwise
operators, in conjunction with a simple macro include in avr-libc:

#include <avr/io.h>
PORTA |= _BV(1);   // Set bit 1
PORTA &= ~_BV(1);    // Clear bit 1

See this thread on the AVR Freaks website on how to use these operators:
<http://www.avrfreaks.net/phpBB2/viewtopic.php?t=8764&highlight=programming+101>
Go to the post that starts with "Programming 101", which should be
highlighted.


If I wanted to do it the "canonical way" would I have ask for it. But I
didn't, did I?

I do wonder how your brain work. I wish I would have taken a degree in
philosophy instead of my master degree in computer science.

But hey, thanks for the link. Here is a link so you can learn some
"Reading 101"
http://www.fisher-price.com/us/ms5/learn-to-read.asp

Enjoy.

#define SETB(REG,POS)   REG|=_BV(POS)
#define CLRB(REG,POS)   REG&=(~_BV(POS))

eg: SETB(UCSRB,TXEN);


reply via email to

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