Quote:
Originally Posted by squiggles
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