lpcware

Consecutive bit assignments in the same register

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Mohannad on Tue Mar 31 03:42:54 MST 2015
Hello,

I'm having a problem regarding assigning bit consecutively in the same register on LPC1769.

For example, to display number 5 on 7 segment display I write this statement and it works perfectly:


Quote:
LPC_GPIO0->FIOPIN = ~(1<<16 | 1<<17 | 1<<7 | 1<<1 | 1<<18);



However, if I have written consecutive statements to assign the same bits, it doesn't work.


Quote:

LPC_GPIO0->FIOPIN |= ~(1<<16) ;
LPC_GPIO0->FIOPIN |= ~(1<<17) ;
LPC_GPIO0->FIOPIN |= ~(1<<7) ;
LPC_GPIO0->FIOPIN |= ~(1<<1) ;
LPC_GPIO0->FIOPIN |= ~(1<<18) ;



I was just curious, why the consecutive bit assignment doesn't work?!

Your help is appreciated.

Thank you,

Outcomes