What's the stock code on the Orangutan these days?

Thank you for the reply Tom.

I like your method better than the whole bit value “BV” thing. To me, the code looks more self-explanatory with the bitfields.

Sounds cool! :wink:

Thanks again!
:slight_smile:

Thank you for the reply Jim.

Initially, I did try scanning through the datasheet for the codes, but I guess I’ll have to do some more thorough reading to really figure this stuff out. Since I’m new to ATmega/AVR, all of the abbreviations/codes look like “greek” to me. :wink:

Thanks again!
:slight_smile:

The one catch with the whole bitfield thing is that it’s not standard C, and may not work on all compilers. It DOES work in WinAVR and should work in avr-gcc in UNIX and OSX. I haven’t tried them, though.

The catch is how the compiler decides to pack its variables. Some compilers may say, “Ok, this is a bit-sized variable, but my smallest variable storage space is one byte.” So you wind up with eight byte-long single-bit variables. They don’t line up right in memory, and things don’t work.

Since that code was written specifically for WinAVR, I don’t see a problem using it. But if you later move to another microprocessor or another compiler, the same thing may or may not work.

But the same can be said of all kinds of things people do when programming, including the CodeVision notation I copied the idea from:

PORTB.2

Works in CodeVision, but nothing else. I can’t tell you how many programs I’ve downloaded that don’t compile right off the bat because of quirky things like that.

Thank goodness porting software keeps the mind nimble.

Tom