Are there any problems if a write/read to/from the port data register (PnD) is performed in the unit of bit instead of in the unit of byte? Are there any possibilities that the non-targeted bits are also changed at operation in the unit of bit?
A write/read to/from the port data register can be performed in the unit of bit. However, please note that the bit manipulation instruction executes the read-modify-write (data is read, and the targeted bit is rewritten and written back) processing. Therefore, when any non-targeted bit is set to input, the input pin state of the port is read, and the data is unintentionally write back to the data register. In this case, the data register may be rewritten when the port is set to output next time. When you want to set the port from input to output, please be sure to set the data register first, and then the port to output.