Skip to main content
Renesas Electronics America - Knowledgebase

"Why access to flag register using bit field leads to clearing of flags? "

Latest Updated:03/04/2015


Access to a flag register with using bit field leads to the clearing of flags other than the target flag or flags. Why does this happen?


In access to a register with using bit field, the values read from the other bits are also written back along with the new value for the target member of the bit field.
Access to a special function register of the MCU with using bit field may, depending on the specification of the device you are using, lead to the setting of an unexpected value for bits other than those in the target member of the bit field.

In the following case, access by the register size and set a value for all bits.

  1. Value in the register changes between reading of the value and writing back the value.
  2. Writing back the value read from the member of bit field is not possible.

Refer to the examples in the following documents for further information.

Take care to check the hardware manual of the target product to make sure that your code is not attempting to violate restrictions the hardware imposes.

Suitable Products
C/C++ Compiler Package for SuperH Family