Port Output Check Function - NEC uPD784038 Series User Manual

16-bit single-chip microcontrollers
Table of Contents

Advertisement

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 :
ERR1 :
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.
CHAPTER 5 PORT FUNCTIONS
SET1
P0.3
; Set bit 3 of port 0
CHKL
P0
; Check port 0
BNE
$ ERR1
; Branch to error processing (ERR1) in case of mismatch with output
.
.
.
CHKLA
P0
; Faulty bit check
BT
A.7, $BIT07
; Bit 7?
BT
A.6, $BIT06
; Bit 6?
.
.
.
BT
A.1, $BIT01
; Bit 1?
BR
$BIT00
; If none of the bits, bit 0 is faulty
User's Manual U11316EJ4V1UD
latch contents
171

Advertisement

Table of Contents
loading

Table of Contents