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
cl -
ock : -
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
-
-
:
-
-
12: 12
-
-
12:
00 00
12:
00
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
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
6.2 APIs and Common Functions Used
ApiStatusType RL_SetTimerReq( unsigned int TimerValue, char TimerMode, int *TimerNo, int *ERcode ); ApiStatusType RL_StartTimer( int TimerNo, int *ERcode ); ApiStatusType RL_CheckTimer( int TimerNo, int *ERcode ); ApiStatusType RL_GetSwPort( char PortNo, char *Indata, int *ERcode ); ApiStatusType RL_Putc_Lcd( char Ylocation, char outc, int *ERcode ); ApiStatusType RL_Putc_LcdLoc( char Xlocation, char Ylocation, char RvTime, const char outc, int *ERcode ); ApiStatusType RL_Puts_LcdLoc( char Xlocation, char Ylocation, char RvTime, const char far* outc, int *ERcode ); void RL_ErrorHook( int FuncNo, int ErrorNo );
For details about the APIs and common functions used by the sample program (24-number time-of-day clock), see the Renesas Starter Kit Library V.1.00 Reference Manual.
REJ05B0810_0110 Rev.1.10
2007.11
Page 6 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
7.
Flowchart
24-number time-of-day clock
Clear display on LCD
Show the initial screen
Input push keys
Adjust hours
Show hours
Low power mode entered YES Process low power mode
NO
Process clock
Process clock display
REJ05B0810_0110 Rev.1.10
2007.11
Page 7 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
8.
1
Tutorial
Launch the HEW by double-clicking its icon.
2
Change the session name from “default Session” to “SessionM16C_E8_System.”
REJ05B0810_0110 Rev.1.10
2007.11
Page 8 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
3 Select “M30260F8A” for Device. Select “Download emulator firmware” for Mode.
REJ05B0810_0110 Rev.1.10
2007.11
Page 9 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
Check the box labeled “Power supply is carried out. (MAX 300mA)” and then select “5.0V.”
REJ05B0810_0110 Rev.1.10
2007.11
Page 10 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
4 In the program and the work RAM text boxes of Firmware Location Address, enter “FA0” and “0B8” respectively. Leave the box labeled “Debug a program using the WDT” unchecked.
REJ05B0810_0110 Rev.1.10
2007.11
Page 11 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
5 Choose Download from the Debug tab and download a module. The upper-side choices for Download show the location from which a project was downloaded.
REJ05B0810_0110 Rev.1.10
2007.11
Page 12 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
6 Click “Start after Reset” to start program execution.
7
Please do "Cancellation" when "The file is opened" window opens.
REJ05B0810_0110 Rev.1.10
2007.11
Page 13 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
9.
Web Sitet
Renesas Technology Web site
http://www.renesas.com/
REJ05B0810_0110 Rev.1.10
2007.11
Page 14 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock) Revision History
Rev. 1.00 1.10 1.20 Date of issue 2006.06.30 2007.07.12 2007.11.29 Content of revision Page First revision issued Contents of presentation improved RSK_LIB APIs supported Points
REJ05B0810_0110 Rev.1.10
2007.11
Page 15 of 16
M16C/26A Group Sample Program (24-Number Time-of-Day Clock)
REJ05B0810_0110 Rev.1.10
2007.11
Page 16 of 16
很抱歉,暂时无法提供与“M16C26A-24NT”相匹配的价格&库存,您可以联系我们找货
免费人工找货