跳至主要內容
Knowledgebase
Home
Renesas Electronics Taiwan - Knowledgebase

Why does the bits modified when using SEB and CLB instructions??

Latest Updated:02/26/2007

Question:

(I/O Port, Pin)  When rewritting the port latch of an I/O port using bit processing instructions (SEB instruction, CLB instruction), the values of unspecified bits may be modified. Why ? [2007/02/26]

Answer:

I/O ports can be set to input or output mode in bit units. Port register reading and writing involve the following operations:

  • Port in input mode
    Read: Read the pin level.
    Write: Write to the port latch.
  • Port in output mode
    Read: Read the port latch or output from peripheral functions
    (specifications differ by port).
    Write: Write to the port latch (the port latch data is output from the pin.)

Since bit processing instructions are read-modify-write instructions*1, using such an instruction on a port register causes reading and writing to be performed simultaneously on bits other than the one specified by the instruction.
When an unspecified bit is in input mode, its pin level is read and that value is written to the port latch. At this time, if the previous value of the port latch differs from the pin level, the port latch value changes.
When an unspecified bit is in output mode, in general the port latch is read. However, for some ports the peripheral function output is read, and the value is written to the port latch. At this time, if the previous value of the port latch differs from the peripheral function output, the port latch value changes.

*1. Read-modify-write instructions: Instructions that read memory in byte units, modify the value, and then write the result to the same location in memory in byte units.

(#106590)

Suitable Products
3803H
3803L
3823
3850A
3858
38D2
38D5
7544
7545
7546
7547
7548
7549