Suppose you want to write something to a 8 bit (or 16 bit) register named REG.
Suppose that REG consists of:
Bit 7-6: option 1 (read/write)
Bit 5: Reserved. Always read as 0. (read only bit)
Bit 4 - 2: option 2 (read/write)
Bit 1: Reserved. Always read as 0. (read only bit)
Bit 0: option 3 (read/write)
supposte i want to set all the options.
Can i write:
REG = 0xDD;
or since bit 5 and bit 1 are reserved read only bits, do i have to write:
REG |= 0xDD;
?
I think this is important because if you can not use the "direct assign", if you want to clear option 1 and set option 2 e 3, you have to do it in 2 steps (&= and |=).
Until now I have always used "the assign" but now I wonder if it's correct.
Regards,
Carloalberto