Mar 22, 2015 #1 M Munna Kumar Newbie level 1 Joined Mar 22, 2015 Messages 1 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 Activity points 6 How to use & and | operater in embeded c? Does it means something if i write IO0PIN&(3<<6)? If yes tell me. How to use & operater if i want to check the status of pin 4 and 7 simultaneously ? Tell me seperately to check for 0 and 1.
How to use & and | operater in embeded c? Does it means something if i write IO0PIN&(3<<6)? If yes tell me. How to use & operater if i want to check the status of pin 4 and 7 simultaneously ? Tell me seperately to check for 0 and 1.
Mar 22, 2015 #2 Easyrider83 Advanced Member level 5 Joined Oct 11, 2011 Messages 1,608 Helped 374 Reputation 748 Reaction score 363 Trophy points 1,363 Location Tallinn, Estonia Activity points 8,575 Re: "io0pin&(3<<5)" io0pin |= (1<<5); // set bit #5 io0pin &= ~(1<<5) // clear bit #5 | - logical OR & - logical AND ~ - inversion - - - Updated - - - if (io0pin & (1<<4) && io0pin & (1<<7)) // true if 4 & 7 bits set
Re: "io0pin&(3<<5)" io0pin |= (1<<5); // set bit #5 io0pin &= ~(1<<5) // clear bit #5 | - logical OR & - logical AND ~ - inversion - - - Updated - - - if (io0pin & (1<<4) && io0pin & (1<<7)) // true if 4 & 7 bits set