NEC 78K0S/K 1+ Series Application Note page 40

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

Advertisement

main.c (C language version)
/*****************************************************************************
NEC Electronics
******************************************************************************
78K0S/KB1+
******************************************************************************
Initialization
******************************************************************************
<<History>>
2007.4.--
******************************************************************************
<<Overview>>
This sample program initializes the microcontroller by setting the 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>
- 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
| (P40) | (P43) | (P20) | (P21) | (P22) |
|---------------|-----------------------|
|
OFF
|
OFF
|
ON
|
OFF
|
OFF
|
ON
|
ON
|
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.
*****************************************************************************/
/*============================================================================
Preprocessing directive (#pragma)
============================================================================*/
#pragma
SFR
source level */
40
APPENDIX A PROGRAM LIST
78K0S/KB1+
Sample program
Release
|
LED1 |
LED2 |
|
OFF
|
OFF
|
|
ON
|
OFF
|
|
OFF
|
ON
|
|
OFF
|
OFF
|
Application Note U18752EJ2V0AN
LED3 |
OFF
|
OFF
|
OFF
|
ON
|
/* SFR names can be described at the C

Advertisement

Table of Contents
loading

This manual is also suitable for:

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

Table of Contents