Main Processing - NEC 78K0S/K 1+ Series Application Note

Led lighting switch control sample program (initial settings)
Hide thumbs Also See for 78K0S/K 1+ Series:
Table of Contents

Advertisement

4.7

Main Processing

The following operations are performed with the main processing in assembly language.
<1> The P4 register data is read.
<2> Among the read 8-bit data, bits except those of the input ports (P40, P43) are cleared to 0.
<3> Output data corresponding to the combination of the P40 and P43 input levels are extracted from addresses
0100H to 0109H ("LEDDATA" table).
<4> The extracted data is output to the P2 register.
Thanks to operations <1> and <2>, only the combination of the input levels of P40 and P43 connected to the
switches (SW1 and SW2) can be identified. In operation <3>, only data of addresses 0100H, 0101H, 0108H, and
0109H, among addresses 0100H to 0109H are used (because there are only four patterns of input level
combinations).
XTBL1 CSEG
LEDDATA:
Address 0100H
MOVW
;*******************************************************************************
;
;
Main loop
;
;*******************************************************************************
MAIN_LOOP:
<1>
MOV
A,
<2>
AND
A,
MOV
L,
<3>
MOV
A,
<4>
MOV
P2,
BR
$MAIN_LOOP
CHAPTER 4 SETTING METHODS
AT
0100H
DB
00000011B
DB
00000101B
DB
00000111B
DB
00000111B
DB
00000111B
DB
00000111B
DB
00000111B
DB
00000111B
DB
00000110B
DB
00000111B
HL,
#LEDDATA
; Set the table address to the
; HL register
Correspondences of bits 0 and 3 between SW1 and SW2, and P4
(a) SW1 = SW2 = ON:
(b) SW1 = OFF, SW2 = ON:
(c) SW1 = ON, SW2 = OFF: P40 = 0, P43 = 1
(d) SW1 = SW2 = OFF:
The address of the A register after operation is 00H ((a)
above), 01H ((b) above), 08H ((c) above), or 09H ((d) above).
P4
; Read switch-input status
#00001001B
; Mask the data except the switch-input status
A
; Set switch-input status to the lower
; 8 bits of the table address
[HL]
; Read LED output data from the table
A
; Output the LED light
; Go to the MAIN_LOOP
Application Note U18752EJ2V0AN
;00: SW1=ON, SW2=ON
;01: SW1=OFF,SW2=ON
;02: Dummy
;03: Dummy
;04: Dummy
;05: Dummy
;06: Dummy
;07: Dummy
;08: SW1=ON, SW2=OFF -> LED1=ON
;09: SW1=OFF,SW2=OFF -> LED1,2,3=OFF
P40 = P43 = 0
P40 = 1, P43 = 0
P40 = P43 = 1
ROM area setting
-> LED3=ON
-> LED2=ON
Main processing
The data of
address 0100H,
0101H, 0108H,
or 0109H (data
of the underlined
part) is read.
Correspondences between the P2
output value and LEDs 1 to 3
(a) P2 = 00000011: Lights only LED3.
(b) P2 = 00000101: Lights only LED2.
(c) P2 = 00000110: Lights only LED1.
(d) P2 = 00000111: Lights off all LEDs.
27

Advertisement

Table of Contents
loading

This manual is also suitable for:

78k0s/ka1+78k0s/kb1+78k0s/ku1+78k0s/ky1+

Table of Contents