![NEC 78K0S/K 1+ Series Скачать руководство пользователя страница 38](http://html.mh-extra.com/html/nec/78k0s-k-1-series/78k0s-k-1-series_application-note_249252038.webp)
APPENDIX A PROGRAM LIST
Application Note U18752EJ2V0AN
38
;*******************************************************************************
XMAIN CSEG UNIT
RESET_START:
;-------------------------------------------------------------------------------
;
Initialize the stack pointer
;-------------------------------------------------------------------------------
MOVW
AX,
#STACKTOP
MOVW SP,
AX
; Set the stack pointer at FF00H
;-------------------------------------------------------------------------------
;
Initialize the watchdog timer
;-------------------------------------------------------------------------------
MOV
WDTM, #01110111B ; Stop the watchdog timer operation
;-------------------------------------------------------------------------------
;
Initialize the clock generators
;-------------------------------------------------------------------------------
MOV
PPCC, #00000010B ; The clock supplied to the peripheral hardware
(fxp) = fx/4 (= 2MHz)
MOV
PCC, #00000000B ; The clock supplied to the CPU (fcpu) = fxp (=
2MHz)
MOV
LSRCM,
#00000001B ; Stop the low-speed internal oscillator
;-------------------------------------------------------------------------------
;
Initialize the port 0
;-------------------------------------------------------------------------------
MOV
PM0, #11110000B ; Set P00-P03 as output mode
MOV
P0,
#00000000B ; Set output latches of P00-P03 as low
;-------------------------------------------------------------------------------
;
Initialize the port 2
;-------------------------------------------------------------------------------
MOV
PM2, #11110000B ; Set P20-P23 as output mode
MOV
P2,
#00000111B ; Set output latches of P20-P22 as high, P23 as
low
;-------------------------------------------------------------------------------
;
Initialize the port 3
;-------------------------------------------------------------------------------
MOV
PM3, #11110000B ; Set P30-P33 as output mode
MOV
P3,
#00000000B ; Set output latches of P30-P33 as low
;-------------------------------------------------------------------------------
;
Initialize the port 4
;-------------------------------------------------------------------------------
MOV
PM4, #00001001B ; Set P40 and P43 as input mode, P41, P42 and P44-
P47 as output mode
MOV
PU4, #00001001B ; Connect on-chip pull-up resistors to P40 and P43
MOV
P4,
#00000000B ; Set output latches of P41, P42 and P44-P47 as
low
;-------------------------------------------------------------------------------
;
Initialize the port 12
;-------------------------------------------------------------------------------
MOV
PM12, #11110000B ; Set P120-P123 as output mode
MOV
P12, #00000000B ; Set output latches of P120-P123 as low
;-------------------------------------------------------------------------------