Dear all ,
I am new to embedded world and C,I am working with MC9S08QG4, I have one basic question in SCI
what is the diff bet SCIS1 = 0xC0; and
SCIS1|= 0xC0;
Thanks in advance.
Added p/n to subject.
Hello,
SCIS1 = 0xC0; means to directly write the SCIS1 register with the value 0xC0.
SCIS1 |= 0xC0; is equivalent to the statement -
SCIS1 = SCIS1 | 0xC0;
This means to read the SCIS1 register, then logical OR the value with 0xC0, and then write the result back to the SCIS1 register. Therefore, the bits that are set within the mask value (0xC0) will also become set within SCIS1, but all other bits of SCIS1 will remain unchanged. This is known as a "read-modify-write" process.
This operation would be true if SCIS1 were a standard read-write register. However, it so happens that this particular register is a special hardware register that is read-only. So write or read-modify-write operations are quite meaninless in this case - the status bits will remain unchanged until a hardware event occurs that sets a particular flag, or the special flag clearing procedures are implemented that do not involve writing to the register.
Regards,
Mac