Bitwise operators and registers

Hello!

I wonder, how can i tweak ON OFF a single bit in register REGx with adress 0x13001200 and write the value back to the same register.

Ty.
Use bitwise OR to switch on a bit and AND with NOT of bit to switch off.
like this?

1
2
REGx = REGx | BITx //turn on
REGx = REGx & ~BITx //turn off 
Yes, if you define BITx as (1<<x)
Or:
1
2
REGx |= BITx //turn on
REGx &= ~BITx //turn off 

It should be evaluated a little faster, I think.
Faster?
Topic archived. No new replies allowed.