Application Notes
M16C/26A Group
Sample Program (24-Number Time-of-Day Clock)
1.
Summary
This sample program provides the functionality of a 24-number time-of-day clock by using the Renesas Starter Kit for M16C/26A
(R0K33026AS000BE).
24-number time-of-day clock
2.
Introduction
Microcomputer: M16C/26A
The example described here applies to the microcomputers listed below.
This sample program runs on the Renesas Starter Kit for M16C/26A (R0K33026AS000BE).
Prepare an extension board available for the Renesas Starter Kit or create a circuit similar to the one shown in the example circuit on
page
??
and then connect it to the Starter Kit.
This program uses RSK_LIB. For details about RSK_LIB, see the RSK_LIB reference manual. (RSK_LIB is the library software provided
for use with the Renesas Starter Kit for M16C/26A.)
REJ05B0810_0110 Rev.1.10
2007.11
Page 1 of 16
M16C/26A Group
Sample Program (24-Number Time-of-Day Clock)
3.
Port Arrangement
LCD
P91
SW1
P83
P90
P63
SW2
P84
P62
P61
SW3
P15
P60
LCD E
LCD R
LCD D7
LCD D6
LCD D5
LCD D4
c l
-
-
o c k
:
-
-
10Mhz
Xin
32.768kHz
Xcin
M30260F8AGP
REJ05B0810_0110 Rev.1.10
2007.11
Page 2 of 16
M16C/26A Group
Sample Program (24-Number Time-of-Day Clock)
4.
Operational Outline
A 24-number digital time-of-day clock is displayed on liquid crystal display.
Press SW3 to go to hours/minutes setup mode, adjust “hours” in the range from 00 o’clock to 23 o’clock using SW1 and SW2, and then
press SW3 to fix the “hours.” Go on and adjust “minutes” in the range from 00 minutes to 59 minutes using SW1 and SW2, and then press
SW3 to fix the “minutes,” letting the time-of-day clock start counting.
After that, operation mode is transitioned from wait mode to low power consumption mode every 1 minute, thereby updating the display of
the time-of-day clock.
Liquid crystal display
1 minute elapsed
Liquid crystal display
1 minute elapsed
M16C26A
M16C26A
SW3
SW2
SW1/
BOOT
SW3
SW2
SW1/
BOOT
SW3 depressed
Wait mode
Low power consumption mode
Low power consumption mode
Wait mode
*Timer A0 (timer mode, main 2 ms cycle)
This timer counts 2 milliseconds using the main clock of the microcomputer as the count source.
It is used as the basic timer of RSK_LIB.
Time management and LCD display management are performed using this timer.
REJ05B0810_0110 Rev.1.10
2007.11
Page 3 of 16
M16C/26A Group
Sample Program (24-Number Time-of-Day Clock)
5.
Operational Specification
(1) Immediately after the reset switch is depressed, the LCD
shows “--:--.”
(2) Pressing the clock setting switch (SW3) places the
program into clock setup mode.
• In “hours” setup mode, the “hours” display flashes at 1
kHz. (During UP/DOWN manipulation, the display flashes
every 500 ms by repeatedly turning on and off.)
(3) Use the UP switch (SW1) to increment the digit by 1 or the
DOWN switch (SW2) to decrement by 1 to adjust the
“hours.”
[Operational specification of the UP and DOWN switches]
When a maximum value is reached, a minimum value
returns. When a minimum value is reached, a maximum
value returns.
If either switch is held down for 1 second or more, the
numeral continuously goes UP or DOWN every 100 ms.
(4) Pressing the clock-setting switch (SW3) fixes the “hours.”
The program goes to “minutes” setup mode.
• In “minutes” setup mode, the “minutes” display flashes at
1 kHz. (During UP/DOWN manipulation, the display flashes
every 500 ms by repeatedly turning on and off.)
(5) Use the UP switch (SW1) to increment the digit by 1 or the
DOWN switch (SW2) to decrement by 1 to adjust the
“minutes.”
(6) Press the clock setting switch (SW3) to fix the “minutes.”
(7) The clock display starts.
• Low power consumption mode
wait mode
[Low power consumption mode]
Main clock oscillation (10 MHz) switched to sub-clock
oscillation (32.768 kHz).
[Wait mode]
The program returns from wait mode every 1 minute,
thereby starting to run.
(8) To reset the time-of-day clock, follow the above setup
steps over again beginning with (1).
(6)Time clock setting
Time of day fixed, start counting
“Minutes” setting
(4) Time clock setting
(5)UP/DN
button
“Hours” setting
(2) Time clock setting
(3) UP/DN
button
(1) Reset start
Time clock not set yet
-
-
:
-
-
1 2
:
1 2
-
-
1 2 :
0 0
0 0
1 2 :
0 0
REJ05B0810_0110 Rev.1.10
2007.11
Page 4 of 16
M16C/26A Group
Sample Program (24-Number Time-of-Day Clock)
6.
Definition of the RSK Functionality and the RSK_LIB APIs and Common Functions Used by the
24-Number Time-of-Day Clock
6.1 Definition of the RSK Functionality
RSKdefine.h file
In this application, the following functionalities (those shown in red) are set.
/*********************************************************
The boot information on CPU is defined
Usually, this mode is used
½所費モードの実行可½
*********************************************************/
//#define _CPU_M16C26A_NORMAL_MOD
/* Use in low power mode can be performed. */
Operation in low power mode executable
#define _CPU_M16C26A_32KHZ_MOD
/* Use of access of a flash can be performed. */
//#define _CPU_M16C26A_DATAFLASF_USE
/********************************************************
The hardware function which RSK supports is chosen
/********************************************************/
//#define _USE_KEY
//#define _USE_BUZZER
//#define _OPTION_USE_AD
//#define _OPTION_USE_COM_RX
//#define _OPTION_USE_COM_TX
//#define _OPTION_USE_INFRAEDRX
//#define _OPTION_USE_INFRAEDTX
Push keys enabled
#define _OPTION_USE_SW
//#define _OPTION_USE_LED
//#define _OPTION_USE_IO
Individual definition of each selected functionality
#if defined _OPTION_USE_SW
#define _OPTION_USE_PUSHSW1
#define _OPTION_USE_PUSHSW2
#define _OPTION_USE_PUSHSW3
#endif
All of SW1–SW3 are enabled.
REJ05B0810_0110 Rev.1.10
2007.11
Page 5 of 16