3.2
Internal Peripheral Functions to Be Used
The following internal peripheral functions of the microcontroller are used in this sample program.
• Input ports (for switch inputs):
• Output ports (for lighting LEDs): P20, P21, P22
3.3
Initial Settings and Operation Overview
In this sample program, the selection of the clock frequency, setting of the I/O ports, and the like are performed in
the initial settings.
After completion of the initial settings, the lighting of the three LEDs (LED1, LED2, LED3) is controlled in
accordance with the combination of the two switch inputs (SW1, SW2).
The details are described in the state transition diagram shown below.
6
CHAPTER 3 SOFTWARE
P40, P43
•
Option byte setting
• Selecting the high-speed internal oscillator as
the system clock source
• The low-speed internal oscillator can be stopped
by software.
• The P34/RESET pin is used as the RESET pin.
•
Stack pointer setting
•
Stopping watchdog timer operation
•
Setting the CPU clock frequency and peripheral
hardware clock frequency to 2 MHz
•
Stopping the oscillation of the low-speed internal
oscillator
•
Setting the I/O ports
Switch input identification
SW1: ON,
SW2: OFF
SW1: OFF,
SW2: OFF
Lighting only LED1
Turning off all LEDs
Application Note U18752EJ2V0AN
Initial settings
SW1: ON,
SW2: ON
SW1: OFF,
SW2: ON
Lighting only LED2
Lighting only LED3