View Single Post
Old 06-08-2009, 09:55 AM   #1628 (permalink)
ga2500ev
EcoModding Lurker
 
Join Date: Nov 2008
Location: Georgia
Posts: 19
Thanks: 1
Thanked 4 Times in 3 Posts
Quote:
Originally Posted by squiggles View Post
Being picky again, and I am sure I am stating something that has been said before. However in my opinion this

PORTB &= (128 + 64 + 32 + 16 + 8 + 4 + 1); // this sets PB1 (the pwm output) to 0 at startup. Notice '2' is missing!


Is better written as
PORTB &= 0xFD; // this clears PB1 (the pwm output) at startup.

I appreciate that hexadecimal may be unfamiliar at first, believe me if you are going to be programming regularly it is highly advisable to become familiar with HEX.
Also in programming speak you don't "set" something to "0".
An even better representation would be in binary if the compiler allows for it.

PORTB &= 0b11111101;

It gives more clarity than either the bitmask or the hex representation.

ga2500ev
  Reply With Quote