User`s manual
DemoKit-LG2 User’s Manual
54
9. Sample Project
The DemoKit-LG2 sample program resides in a single directory called main-directory, which contains
all of the output files for NEC Electronics’ integrated development environment (IDE).
The main directory contains the workspace and project files. All source files and associated files are
located in the directory. The workspace file is named DemoKit-LG2.prw is provided to demonstrate
the 78K0/LG2 MCU’s functionality.
9.1 Real-Time Clock
This part of the sample project realizes a real-time clock. After the program initializes, the watch timer
generates an exact clock reference based on the 32.768 kHz subclock and the LCD displays the time in
either 24-hour or AM/PM clock format, depending on the setting selected.
9.2 Temperature Measurement
Temperature is measured using the dual-slope method to convert the temperature sensor’s resistor value
into a digital counter-value. To do this, the MCU 16-bit timer/event counter 00 measures the charging
time of the C
18 capacitor. The first charging slope uses a reference resistor (RREF = R6) and the second a
variable resistor (R
VAR= R5 + RT), which should be determined. The variable resistor of the temperature
sensor, and consequently the temperature, can be calculated by comparing the two measured times and
the known R
REF reference resistor. The LCD displays the temperature in degrees Celsius or degrees
Fahrenheit, depending on the setting selected. Additionally, the temperature is transferred via UART6 at
the default data transfer speed of 115200 bits per second to a terminal program running on the host
computer.
9.3 Light Incidence Measurement
This part of the sample project measures light incidence. The MCU’s A/D converter (channel 0) is used
to measure a voltage cycle at the phototransistor and the result is converted into a percent value and
displayed on the LCD.
9.4 Buzzer Output Example
This demonstration drives the buzzer by using the 16-bit timer/event counter 01. The timer is
configured to generate a rectangular waveform. By changing the output frequency of the timer, the
buzzer can generate different tones. For demonstration purposes, a simple melody is played.
9.5 Menu Selection
To shift between the different operating modes of the sample project, follow the menu configuration
shown in Figure 64. The first column shows the main menus and the second the sub-menus. Move SW3
up or down to switch from one menu to another and from left to right to switch between sub-menus.