Application Note U18752EJ2V0AN
36
APPENDIX A PROGRAM LIST
As a program list example, the 78K0S/KB1+ microcontroller source program is shown below.
z
main.asm (Assembly language version)
;*******************************************************************************
;
;
NEC Electronics 78K0S/KB1+
;
;*******************************************************************************
; 78K0S/KB1+
Sample
program
;*******************************************************************************
; Initialization
;*******************************************************************************
;<<History>>
; 2007.4.--
Release
;*******************************************************************************
;
;<<Overview>>
;
; This sample program initializes the microcontroller by setting functions
; such as clock frequency and the port to the input or output.
; After the initialization, three LED lights are controlled by two switches.
;
; <Principal setting contents in initialization>
;
; - Set the vector table
; - Set the stack pointer
; - Stop the watchdog timer operation
; - Set the CPU clock frequency at 2 MHz
; - Stop the low-speed internal oscillator
; - Set the ports to the input or output mode
; - Set the connection of on-chip pull-up resistors (input port only)
; - Set the output latches of the output ports
;
;
; <Switch input and LED output>
;
; +---------------------------------------+
; | SW1 | SW2 | LED1 | LED2 | LED3 |
; | (P40) | (P43) | (P20) | (P21) | (P22) |
; |---------------|-----------------------|
; | OFF | OFF | OFF | OFF | OFF |
; | ON | OFF | ON | OFF | OFF |
; | OFF | ON | OFF | ON | OFF |
; | ON | ON | OFF | OFF | ON |
; +---------------------------------------+
;
;
;<<I/O port settings>>
;
; Input: P40, P43
; Output: P00-P03, P20-P23, P30-P33, P41, P42, P44-P47, P120-P123, P130
; # All unused ports are set as the output mode.
;
;*******************************************************************************