Content originally posted in LPCWare by fjrg76 on Tue Jul 28 22:32:39 MST 2015
Hi
You are using:
LPC_GPIO0 -> CLR = (1 << bitPosi); // (1)
but you forgot the OR '|' operator:
LPC_GPIO0 -> CLR |= (1 << bitPosi); // (2)
LPC_GPIO0 -> SET |= (1 << bitPosi); // (2)
Do you see the difference? In (1) you're setting the whole register to the (1<<bitPosi) value, but that's not what you want. In (2) you're clearing (or setting) ONLY the bit specified in bitPosi.
If you're not used to the compact sintax of C:
LPC_GPIO0 -> CLR |= (1 << bitPosi);
is the same as:
LPC_GPIO0 -> CLR = LPC_GPIO0 -> CLR | (1 << bitPosi);
(Same thing as
x+=5;
or
x = x + 5;
)