
CHAPTER 5 PORT FUNCTIONS
161
5.10 PORT OUTPUT CHECK FUNCTION
The
μ
PD784038 has a function for reading and testing output port pin levels in order to improve the reliability of application
systems. It is therefore possible to check the output data and the actual pin status as required. If there is a mismatch, appropriate
action can be taken, such as replacement with another system.
Special instructions, CHKL and CHKLA, are provided to check the port status. These instructions perform a comparison by
taking the exclusive OR of the pin status and the output latch contents (in port mode), or the pin status and the internal control
output signal level (in control mode).
Example
An example is shown below of a program that checks the pin status and output latch contents using the CHKL
instruction and CHKLA instruction.
TEST :
SET1
CHKL
BNE
P0.3
P0
$ ERR1
; Set bit 3 of port 0
; Check port 0
; Branch to error processing (ERR1) in case of mismatch with output
latch contents
.
.
.
ERR1 :
CHKLA
BT
BT
P0
A.7, $BIT07
A.6, $BIT06
; Faulty bit check
; Bit 7
; Bit 6
.
.
.
BT
BR
A.1, $BIT01
$BIT00
; Bit 1
; If none of the bits, bit 0 is faulty
Cautions 1. If each port is set to input mode, a comparison of the pin status with the output latch contents (or
control output level) using the CHKL or CHKLA instruction will always show a match whether the
individual pins of the port are port pins or control pins.
Therefore, executing these instructions on a port set to input mode is actually ineffective.
2. If the output levels of a port in which control outputs and port outputs are mixed in a single port are
checked with the CHKL or CHKLA instruction, the input/output mode of control output pins should
be set to input mode before executing these instructions (as the output levels of control outputs vary
asynchronously, the output level cannot be checked with the CHKL or CHKLA instruction).
3. As port 2 is an input-only port, a comparison of the pin status with the output latch contents using
the CHKL or CHKLA instruction will always show a match. Therefore, executing these instructions
on port 2 is actually ineffective.