Getting Started

(lily) #1

Chapter 4: C Types, Operators, and Expressions


else if( (TCC0RA & WGM01) && (TCC0RA & WGM00) )

bitwise ANDs and a logical

Assignment Operators and Expressions


able 6: Assignment Operators

O


{
// do this only if in the Fast PWM mode
}


The (TCC0RA & WGM01) test will be 1, true, only if the WGM01 bit is 1,
likewise for the (TCC0RA & WGM00) statement. The !(TCC0RA & WGM01),
adding the ‘!’ or NOT to the statement means that it is true only if the innards of
the () are false. The ‘if’ statement will only be true if both the first and (logical
AND = &&) the second are true. So we’ve used two
AND in this statement.


AND I hope it is clear. It isn’t, so get out the pencil and paper computer and work
through it till it is. Seriously, when I was editing and reread this section I had a
‘good grief’ moment. But this is critical since we will be doing lots of clearing
and setting control register bits. And it is as simple as I can make it, so do
carefully walk through the example, pencil and paper in hand and work each
example.


A


T

perator Name Example Defined
= Assignment x=y Put the value of y into x
+=
-=


Compound
assignment

x += y This provides a short cut way to write and
expressio
*=
/=
%=
<<=



=



n, the example:
x += y; is the same as


&=
^=
|=



x = x + y;
Free download pdf