[Top][All Lists]
[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: |
Larry Barello |
Subject: |
RE: [avr-gcc-list] Efficient I/O handling w. bitfields codegen problem |
Date: |
Thu, 2 Dec 2004 16:16:39 -0800 |
There is no need to get snotty about miscommunications. Eric was probably
rushed and typed too fast :)
The use of bitfields for register access was discussed a couple months ago.
It should work. I dunno why your struct of unions didn't because when I
make a super-struct of most of the classic AVR I/O registers it worked
exactly how you wanted it to.
Oh, I see, I looked at my initial rough cut: I didn't do a super structure,
but individual unions for each I/O register and named each one the same (bad
idea, I know) as the Atmel register names.
Ned Konz had a very nice mechanism which he published recently including a
tool to convert the Atmel header files to the union technique. I attached
that letter (I hope attachments are ok on this list...)
Cheers!
-----Original Message-----
From: Albert Seward
...
> >
>
> 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.
Albert Seward
Uppsala University Sweden
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Efficient I/O handling w. bitfields codegen problem, Ned Konz, 2004/12/02