Forum: Mikrocontroller und Digitale Elektronik a question


von stefan2005 (Gast)


Lesenswert?

I want to kown the differece between PIOUT&=~BIT0 andPIOUT ^=BIT0. they 
are all Reset  ,all right ?

von dsa (Gast)


Lesenswert?

yes right

von Johannes M. (johnny-m)


Lesenswert?

No!

von Feadi F. (feadi)


Lesenswert?

Neeeeeee....

PIOUT ^= BIT0
^ ist die XOR-Funktion.

Daher ist das ein Pin-Toggle.

von marvin (Gast)


Lesenswert?

Hi,

PIOUT&=~BIT0 resets (while BIT0 must be a bitmask) while PIOUT ^=BIT0 is 
a "exlusive or", i.e. it reverses.


von Karl H. (kbuchegg)


Lesenswert?

> I want to kown the differece between PIOUT&=~BIT0 andPIOUT ^=BIT0. they
> are all Reset  ,all right ?

No.
&  means and
^  means xor (exclusive or)

So in the first case bit BIT0 gets reset.
But in the second case the bit gets toggled. It depends
on the previous state of of the bit what its new state
will be. 0 toggles to 1, 1 toggles to 0

> thank you!
you are welcome

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.