Using winAVR for the following code.
I got an 8-bit PIN here that I need to OR it with 00000010 or 0x02 to set the 7th bit.
Now what I have to do is the following :
BUT, I shouldn't change the other bits in these steps.
So I have to :
So my test code is :
B=PINB|0x02
Loop delay for 1ms
BP=PINB&0x00
Loop for 19ms
But I think that the other bits are going to be altered in this process, my question is, HOW am I supposed to manipulate one bit of an 8 bit port without changing the other bits ?
Thanks alot !!
You need BP=PINB & ~0x02
The ~ operator is logical NOT. The and operator keeps only the bits other than 2.