R8C-3MT [RENESAS]

Sample Program: 3-Minute Timer; 示例程序: 3分钟计时器
R8C-3MT
型号: R8C-3MT
厂家: RENESAS TECHNOLOGY CORP    RENESAS TECHNOLOGY CORP
描述:

Sample Program: 3-Minute Timer
示例程序: 3分钟计时器

文件: 总21页 (文件大小:106K)
中文:  中文翻译
下载:  下载PDF数据表文档文件
APPLICATION NOTE  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
1. Abstract  
The 3-minute timer uses the following functions:  
• Timer X (timer mode)  
• Timer Z (programmable waveform generation mode)  
2. Introduction  
The example described in this application note is intended for use in the R8C/17 group of  
microcomputers.  
This program can also be used when operating other microcomputers within the R8C/Tiny, provided  
they have the same SFR (Special Function Registers) as the R8C/17 microcomputers. However, since it  
is possible that some functions of the R8C/Tiny series will have been altered for functional  
enhancements, etc., please be sure to obtain the SFR header file from the Renesas Web site shown  
below.  
http://www.renesas.com/en/r8ctiny  
Operation (1) The 3-minute timer has two separate modes:  
• Standby mode  
• 3-minute timer mode  
SW4(INT0)  
Standby mode Key depressed  
3-minute timer mode  
After reset  
SW1(CNTR0)  
Key depressed  
(2) After reset, the microcomputer goes to standby mode.  
(3) If SW4 (INT0) is pressed during standby mode, the microcomputer goes to 3-minute timer  
mode.  
(4) In 3-minute timer mode, the microcomputer executes a 3-minute count operation.  
(5) When the microcomputer has finished counting 3 minutes, it sounds a buzzer two times  
and goes to standby mode. (Buzzer operation will be detailed later.)  
(6) If SW1 (CNTR0) is pressed during 3-minute timer mode, the microcomputer goes to  
standby mode.  
(7) Key input is sampled at 10 ms intervals, and is confirmed to have been entered when  
sampled low three times consecutively. (Chattering elimination)  
(8) The key inputs SW4 (INT0) and SW1 (CNTR0) are active-low. (When low, the key is  
pressed; when high, not pressed.)  
(9) During 3-minute timer mode, the status is indicated by LEDs according to the passage of  
time, as shown below.  
LED indications for the passage of time:  
LED1 (red)  
LED2 (green)  
LED3 (green)  
LED4 (green)  
2 minutes or more remaining time  
1 minute or more remaining time  
Off  
Off  
Off  
Off  
On  
On  
Flashes every  
500 ms  
Flashes every  
500 ms  
Off  
Off  
On  
Off  
Off  
Off  
Flashes every  
500 ms  
Off  
10 seconds or more remaining time  
Flashes every  
250 ms  
Off  
Off  
10 seconds or less remaining time  
0 second remaining time (buzzer sounded)  
Off  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 1 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
(10) During standby mode, the status is indicated by LEDs, as shown below.  
LED indications during standby mode:  
LED1 (red)  
LED2 (green)  
Off  
LED3 (green)  
Off  
LED4 (green)  
Off  
During standby mode  
On  
(11) The LED1, LED2, LED3 and LED4 are active-low. (When low, the LED lights; when  
high, the LED goes out.)  
(12) The buzzer on/off signal is output from P13 (TZOUT) using timer-Z programmable  
waveform mode.  
(13) The buzzer is output with 1 kHz (50% duty cycle), repeatedly turned on and off twice at  
200 ms intervals, and at the end of the sequence, turned off again for another 200 ms.  
Buzzer output timing sequence:  
Sequence No.  
1
2
3
4
Buzzer status  
Output and stop time  
ON (output)  
200 ms  
OFF (stop)  
200 ms  
ON (output)  
200 ms  
OFF (stop)  
400 ms  
3. About the Program  
3.1 Timer X (Timer Mode)  
The timer X (timer mode) is used to maintain a constant main loop period.  
The set value of the timer X is shown below.  
100µs  
Timer X  
Prescaler X  
Main loop, 10 ms  
1/8  
20MHz  
Set value = (100 – 1)  
Set value = (250 – 1)  
Settings of the Timer X Mode Register  
b7  
b0  
Timer X Mode Register [address 008B16] TXMR  
0 0 0 0 1 0 0 0  
Selects timer mode  
INT1/CNTR0 polarity select bit  
Timer X count start flag Set to “1” when count starts  
Set to “0” in timer mode  
Other than pulse period measurement mode  
Set to “0” in timer mode  
Settings of the Timer Count Source Setup Register  
b7  
b0  
Timer Count Source Setup Register [address 008E16] TCSS  
0 0 0 1 0 0 0 1  
Timer X count source Set 01: 1/8  
Reserved bit. Set to “0”.  
Timer Z count source Set 01: 1/8  
Reserved bit. Set to “0”.  
When the respective registers are set up as shown above, the timer X interrupt request bit is cyclically  
set at 10 ms intervals.  
Before the main processing, the program checks the timer X interrupt request bit to see if 10 ms has  
elapsed. If 10 ms has elapsed, the program clears the timer X interrupt request bit and executes the  
main processing. If 10 ms has not elapsed yet, the program waits until the timer X interrupt request bit  
is set.  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 2 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
3.2 Timer Z (Programmable Waveform Generation Mode)  
The timer Z (programmable waveform generation mode) is used to sound a buzzer.  
Waveform generation with 1 kHz (50% duty cycle) is accomplished by setting up the registers as shown  
below. The output level is set by using the timer Z output level latch (TZOPL) in the Timer Z Waveform  
Output Control Register (PUM). Setting the timer Z output level latch (TZOPL) to “0” causes the device  
to output a high during the primary period, a low during the secondary period, and a low when the  
timer is inactive.  
Settings of the Timer Z Waveform Output Control Register  
b7  
b0  
Timer Z Waveform Output Control Register [address 008416] PUM  
Reserved bit. Set to “0”.  
0 0 0 0 0 0 0 0  
Timer Z output level latch  
High during primary period, low during secondary period, and low when the timer is  
inactive  
INT0 pin one-shot trigger control bit  
INT0 pin one-shot trigger polarity select bit  
When the timer Z starts counting, the device outputs a high during the primary period and a low during  
the secondary period from P13 (TZOUT), and when the timer Z stops counting, the device outputs a low.  
The timer Z set values are shown below.  
Buzzer output =  
high, 500 µs  
Timer Z primary  
10µs  
Prescaler Z  
1/8  
20MHz  
Set value = (50 – 1)  
Set value = (25 – 1)  
Timer Z secondary  
Set value = (50 – 1)  
Buzzer output =  
low, 500 µs  
Settings of the Timer Count Source Setup Register  
b7  
b0  
Timer Count Source Setup Register [address 008E16] TCSS  
Timer X count source Set 01: 1/8  
0 0 0 1 0 0 0 1  
Reserved bit. Set to “0”.  
Timer Z count source Set 01: 1/8  
Reserved bit. Set to “0”.  
Settings of the Timer Z Mode Register  
b7  
b0  
Timer Z Mode Register [address 008016] TZMR  
0 1 0 1 0 0 0 0  
Reserved bit. Set to “0”.  
01: Programmable waveform generation mode  
Set to “1” in programmable waveform generation mode.  
Timer Z count start flag  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 3 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
3.3 Chattering Elimination  
To protect the key input against chattering noise, SW1 and SW4 are read multiple times to confirm that  
the detected input levels are the same. For the 3-minute timer, key input is sampled at 10 ms intervals,  
and is confirmed to have been entered when sampled low three times consecutively.  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 4 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
4. Flowchart  
4.1 Initial Settings and Main Loop  
Reset  
; Disables interrupts  
asm("FCLR I");  
prcr = 1;  
; Removes protection of the system control registers  
; XIN-XOUT pin  
cm13 = 1;  
cm15 = 1;  
cm05 = 0;  
cm16 = 0;  
cm17 = 0;  
cm06 = 0;  
asm("nop");  
asm("nop");  
; Selects XIN-XOUT drive capability; set to HIGH  
; Main clock oscillation  
; Main clock not divided  
; Enables main clock division CM16, CM17  
; Wait until stabilizes  
; Wait until stabilizes  
; Wait until stabilizes  
asm("nop");  
asm("nop");  
ocd2 = 0;  
; Wait until stabilizes  
; Selects the main clock  
; Protects the system control registers  
; Initializes the SFR (port initialization and timer setup)  
prcr = 0;  
Initialize SFR  
SFR_INITIAL  
; Enables interrupts  
asm("FSET I");  
; Wait for timer X request  
No  
Main period elapsed (10 ms)?  
Yes  
; Clears the timer X request flag  
ir txic = 0;  
; Refreshes the port direction register  
Reset SFR  
SFR_REF  
Port output  
PORT_OUT  
; Sets the port for output (LED and buzzer)  
; Sets the port for input (key input processing)  
; Soft timer (10 ms based timer value subtraction)  
Port intput  
PORT_IN  
Soft timer processing  
STIMER  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 5 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
4.2 SFR Initialization  
sfr_init  
p1 = 0x16;  
p4 = 0;  
; Initializes port P1  
; Initializes port P4  
tcss = 0x11;  
prex = 250-1  
tx = 100-1;  
txs = 1;  
; Timer X = divided-by-8, timer Z = divided-by-8  
; Prescaler X = 250 –1  
; Timer X = 100 – 1  
; Timer X starts counting  
prez = 25-1;  
; Prescaler Z = 25 – 1  
tzsc = 50-1;  
tzpr = 50-1;  
tzmr = 0x50;  
pum = 0;  
; Timer Z secondary register = 50 – 1  
; Timer Z primary register = 50 – 1  
; Timer Z mode = programmable waveform generation mode  
; Timer Z waveform output control register = 0  
; Timer Z stops counting  
tzs = 0;  
; Refreshes the SFR  
Refresh SFR  
sfr_ref  
RTS  
4.3 SFR Refresh  
sfr_ref  
pd1 = 0x1E;  
pd4 = 0;  
; Initializes/refreshes the port P1 direction register  
; Initializes/refreshes the port P4 direction register  
RTS  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 6 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
4.4 Port Output  
port_out  
No  
mode = 1  
; Turns only the red LED on  
; Turns buzzer off  
p1 = 0x06;  
tzs = 0;  
Yes  
No  
tm_ledon <= 0  
RTS  
Yes  
Yes  
cnt3min > 12000  
Led_on = 1;  
No  
No  
cnt3min > 1000  
Yes  
; Sets LED-on time  
tm_ledon = 25;  
tm_ledon = 50;  
No  
; Switches over LED on/off  
led_on = 0  
Yes  
led_on = 0;  
led_on = 1;  
Yes  
led_on = 1  
; LED turn-on processing by time  
Yes  
No  
cnt3min > 6000  
No  
p1 = 0x10;  
Yes  
cnt3min > 0  
No  
p1 = 0x12;  
p1 = 0x06;  
No  
cnt3min = 0  
; Buzzer output  
currently on  
Yes  
; LED turn-off processing  
p1 = 0x16;  
p1 = 0x06;  
1
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 7 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
1
No  
No  
; Determines buzzer output  
tm_buzzer = 20;  
cnt3min = 0 & mode = 1  
Yes  
; Buzzer output currently on or turned off  
tm_buzzer <= 0  
Yes  
RTS  
tm_buzzer = 20;  
Yes  
Yes  
md_buzzer = 0  
No  
md_buzzer = 2  
; Timer Z starts counting  
tzs = 1;  
No  
; Sets buzzer mode  
md_buzzer + 1;  
RTS  
Yes  
Yes  
Yes  
md buzzer = 1  
No  
md_buzzer = 3  
No  
md_buzzer = 4  
No  
; Timer Z stops counting  
tzs = 0;  
; Sets buzzer mode  
md_buzzer + 1;  
RTS  
mode = 0;  
; Mode = standby mode  
; Initializes buzzer mode  
md_buzzer = 0;  
RTS  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 8 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
4.5 Port Input  
port_in  
i = 1;  
No  
SW4 = SW_ON  
Yes  
i = 0;  
sw4_bit << 1;  
sw4_bit | i;  
; Reserves storage in which to save the input data  
; Saves the input data  
sw4_bit & 7;  
; Deletes 5 high-order bits  
No  
sw4_bit = 0 | sw4_bit = 7  
Yes  
No  
sw4_bit = 0  
Yes  
; Valid data = high  
; Valid data = low  
fixsw4 = 1;  
fixsw4 = 0;  
No  
mode = 0  
Yes  
; Changes modes  
mode = 1;  
; Sets 3-minute time  
cnt3min = 18000;  
; Starts from LED off  
led_on = 0;  
i = 1;  
No  
SW1 = SW_ON  
Yes  
i = 0;  
sw1_bit << 1;  
sw1_bit | i;  
; Reserves storage in which to save the input data  
; Saves the input data  
sw1_bit & 7;  
; Deletes 5 high-order bits  
2
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 9 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
2
No  
sw1_bit = 0 | sw1_bit = 7  
Yes  
No  
sw1_bit = 0  
; Valid data = high  
Yes  
fixsw1 = 1;  
; Valid data = low  
fixsw1 = 0;  
No  
mode = 1  
Yes  
mode = 0;  
cnt3min = 0;  
RTS  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 10 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
4.6 Soft Timer Processing  
stimer  
No  
No  
; Mode = 3-minute timer mode  
mode = 1  
Yes  
; Checks for underflow  
cnt3min != 0  
Yes  
cnt3min - 1;  
; Subtracts 3-minute measurement timer  
; Checks for underflow  
No  
tm_ledon != 0  
Yes  
tm_buzzer - 1;  
; Subtracts LED-on time  
No  
tm_buzzer != 0  
; Checks for underflow  
Yes  
tm_ledon - 1;  
; Subtracts buzzer-on time  
RTS  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 11 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
5. Sample Program  
/************************************************************************************  
*
*
*
*
*
*
*
*
*
*
*
*
File Name  
Contents  
: 3min_timer.h  
: definition of R8C/17 Group SFR  
Copyright, 2004 RENESAS TECHNOLOGY CORPORATION  
AND RENESAS SOLUTIONS CORPORATION  
Version  
note  
*
: 1.00  
:
*
*
*
************************************************************************************/  
/* Definition of RAM area */  
char mode  
= 0;  
= 0;  
= 1;  
= 0;  
= 1;  
/* Mode number */  
/* Input SW1 data */  
/* Input SW1 Settlement data */  
/* Input SW4 data */  
/* Input SW4 Settlement data */  
char sw1_bit  
char fixsw1  
char sw4_bit  
char fixsw4  
char md_buzzer;  
char led_on;  
/* Buzzer control mode */  
/* Display on-off */  
unsigned int tm_ledon;  
unsigned int tm_buzzer;  
unsigned long int cnt3min;  
/* LED control timer */  
/* Buzzer control timer */  
/* Counting area in the 3 minute timer */  
/* Declaration of function prototype */  
extern void sfr_init(void);  
extern void sfr_ref(void);  
extern void port_out(void);  
extern void port_in(void);  
extern void stimer(void);  
/* Initial setting of SFR registers */  
/* Refresh of SFR registers */  
/* Port output */  
/* Port input */  
/* Software timer */  
/* Definition of base section */  
#define SW_ON  
#define SW_OFF  
#define LOW  
0
1
0
1
#define HIGH  
/* Definition of port */  
#define GREEN_LED2 p1_1  
#define GREEN_LED1 p1_2  
#define GREEN_LED0 p1_3  
#define RED_LEDp1_4  
#define SW1  
#define SW4  
#define BUZZER  
p1_7  
p4_5  
p1_3  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 12 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
/************************************************************************************  
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
File Name  
Contents  
: main.c  
: definition of R8C/17 Group SFR  
Copyright, 2004 RENESAS TECHNOLOGY CORPORATION  
AND RENESAS SOLUTIONS CORPORATION  
Version  
note  
: 1.00  
:
************************************************************************************/  
#include "sfr_r817.h"  
#include "3min_timer.h"  
/* Definition of the R8C/17 SFR */  
/* Definition of processing for 3 minutes timer */  
main(){  
asm("FCLR I");  
prcr = 1;  
cm13 = 1;  
cm15 = 1;  
cm05 = 0;  
cm16 = 0;  
cm17 = 0;  
cm06 = 0;  
asm("nop");  
asm("nop");  
asm("nop");  
asm("nop");  
ocd2 = 0;  
prcr = 0;  
/* Interrupt disable */  
/* Protect off */  
/* X-in X-out */  
/* XCIN-XCOUT drive capacity select bit : HIGH */  
/* X-in on */  
/* Main clock = No division mode */  
/* CM16 and CM17 enable */  
/* Main clock change */  
/* Protect on */  
sfr_init();  
/* Initial setting of SFR registers */  
while(1){  
/* Main processing */  
/* Interrupt enable */  
/* Main cycle 10ms */  
asm("FSET I");  
while(ir_txic == 0){}  
ir_txic = 0;  
sfr_ref();  
port_out();  
port_in();  
stimer();  
/* Refreshment of SFR registers */  
/* Port output */  
/* Port input */  
/* Software timer */  
}
}
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 13 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
/************************************************************************************  
Name: sfr_init  
Parameters: None  
Returns: None  
Description: Initial setting of SFR registers  
************************************************************************************/  
void sfr_init(void){  
/* Setting port registers */  
p1 = 0x16;  
/* p14,12,11 = H(Led 4.-.2.1) P13 = L(Buzzer) */  
p4 = 0;  
tcss = 0x11;  
/* division = X:1/8,Z:1/8 */  
/* Setting main cycle timer  
/* 20MHz* 1/8 * 250 * 100 =10ms  
prex = 250 - 1;  
tx = 100 - 1;  
txs = 1;  
*/  
*/  
/* Setting Prescaler X register */  
/* Setting timer X register */  
/* Timer X count start flag = start */  
/* Setting Buzzer output timer */  
/* the period of Timer Z primary = 20MHz* 1/8 * 25 * 50 = 0.5ms */  
/* the period of Timer Z secondary = 20MHz* 1/8 * 25 * 50 = 0.5ms */  
prez = 25 - 1;  
tzsc = 50 - 1;  
tzpr = 50 - 1;  
tzmr = 0x50;  
pum = 0;  
/* Setting Prescaler Z register */  
/* Setting timer Z secondary register */  
/* Setting timer Z Primary register */  
/* Timer Z mode = Programmable waveform generation mode */  
/* Timer Z waveform output control register */  
/* Timer Z count start flag = stop */  
tzs = 0;  
sfr_ref();  
/* Refreshment of SFR registers */  
}
/************************************************************************************  
Name: sfr_ref  
Parameters: None  
Returns: None  
Description: Refresh of SFR registers  
************************************************************************************/  
void sfr_ref(void){  
/* Setting port direction registers */  
pd1 = 0x1E;  
pd4 = 0x0;  
}
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 14 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
/************************************************************************************  
Name: port_out  
Parameters: None  
Returns: None  
Description: Port output  
************************************************************************************/  
void port_out(void){  
if (mode == 1){  
/* LED output processing */  
if (tm_ledon <= 0){  
if (cnt3min > 12000){  
/* The remainder time is more than 2 minutes */  
led_on = 1;  
}else{  
if (cnt3min > 1000){  
/* Change of LED control timer */  
/* Display during 500ms */  
tm_ledon = 50;  
}else{  
tm_ledon = 25;  
/* Display during 250ms */  
}
if (led_on == 0){  
/* Change of display on-off */  
/* Display start */  
led_on = 1;  
}else{  
led_on = 0;  
/* Display stoppage */  
}
}
}
if (led_on == 1){  
if (cnt3min > 6000){  
/* The remainder time is more than 1 minutes */  
/* The remainder time is less than 1 minutes */  
/* The remainder time is nothing */  
p1 = 0x10;  
}else if (cnt3min > 0){  
p1 = 0x12;  
}else{  
p1 = 0x06;  
}
}else{  
if (cnt3min == 0){  
p1 = 0x06;  
}else{  
p1 = 0x16;  
}
/* Counting end */  
/* LED turn-off */  
}
/* Buzzer output processing */  
if (cnt3min == 0 && mode == 1){  
if (tm_buzzer <= 0){  
tm_buzzer = 20;  
/* Buzzer control timer = 200ms */  
/* Counting start of timer Z */  
switch (md_buzzer){  
case 0:  
case 2:  
tzs = 1;  
md_buzzer = md_buzzer + 1;  
break;  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 15 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
case 1:  
case 3:  
case 4:  
tzs = 0;  
/* Counting stoppage of timer Z */  
md_buzzer = md_buzzer + 1;  
break;  
default:  
mode = 0;  
/* Move to the standby mode */  
md_buzzer = 0;  
}
}
}else{  
tm_buzzer = 20;  
/* Buzzer output of 200ms */  
/* Timer Z stops Counting */  
}
}else{  
p1 = 0x06;  
tzs = 0;  
}
}
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 16 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
/************************************************************************************  
Name: port_in  
Parameters: None  
Returns: None  
Description: Port input  
************************************************************************************/  
void port_in(void){  
unsigned char i;  
/* Determination of input level SW4 */  
i = 1;  
if (SW4 == SW_ON)i = 0;  
/* Now determination SW4 */  
sw4_bit = sw4_bit << 1;  
sw4_bit = sw4_bit | i;  
sw4_bit = sw4_bit & 7;  
/* Check pulses matching a trigger input level 3 times */  
if (sw4_bit == 0 || sw4_bit == 7){  
if (sw4_bit == 0){  
/* Determinate input SW4 */  
/* Input on */  
fixsw4 = 0;  
/* Counting start of the 3 minutes timer */  
if (mode == 0){  
mode = 1;  
/* Setting the 3 minute timer mode */  
/* Initialization of the 3 minutes timer */  
/* Display start */  
cnt3min = 18000;  
led_on = 0;  
}
}else{  
fixsw4 = 1;  
/* Input off */  
}
}
/* Determination of input level SW1 */  
i = 1;  
if (SW1 == SW_ON)i = 0;  
/* Now determination SW1 */  
sw1_bit = sw1_bit << 1;  
sw1_bit = sw1_bit | i;  
sw1_bit = sw1_bit & 7;  
/* Check pulses matching a trigger input level 3 times */  
if (sw1_bit == 0 || sw1_bit == 7){  
/* Determinate input SW1 */  
/* Input on */  
if (sw1_bit == 0){  
fixsw1 = 0;  
if (mode == 1){  
mode = 0;  
/* Setting the standby mode */  
cnt3min = 0;  
}
}else{  
fixsw1 = 1;  
/* Input off */  
}
}
}
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 17 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
/************************************************************************************  
Name: stimer  
Parameters: None  
Returns: None  
Description: Software timer  
************************************************************************************/  
void stimer(void){  
/* Countdown of 3 minutes timer */  
if (mode == 1){  
if (cnt3min != 0){  
cnt3min = cnt3min - 1;  
}
}
/* Countdown of LED control timer */  
if (tm_ledon != 0){  
tm_ledon = tm_ledon - 1;  
}
/* Countdown of buzzer control timer */  
if (tm_buzzer != 0){  
tm_buzzer = tm_buzzer - 1;  
}
}
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 18 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
6. Reference Documents  
Datasheet  
R8C/Tiny Series Datasheet  
(For the most current version, please visit Renesas Technology Home Page )  
Hardware Manual  
R8C/Tiny Series Hardware Manual  
(For the most current version, please visit Renesas Technology Home Page)  
7. Home Page and Support Information Window  
Renesas Technology Home Page  
http://www.renesas.com/  
M16C Family MCU Technical Support Information Window  
support_apl@renesas.com  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 19 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
REVISION HISTORY  
Description  
Summary  
Rev.  
1.00  
1.10  
2.00  
Date  
Page  
-
Sep 09, 2003  
Nov 10, 2003  
Jul 1, 2004  
First edition issued  
For R8C/11 Group  
For R8C/Tiny Series  
ALL  
ALL  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 20 of 21  
R8C/Tiny Series  
Sample Program: 3-Minute Timer  
Keep safety first in your circuit designs!  
Keep safety first in your circuit designs!  
Notes regarding these materil
1. Renesas Technology Corporation puts the maximum effort into making semiconductor products  
better and more reliable, but there is always the possibility that trouble may occur with them. Trouble  
with semiconductors may lead to personal injury, fire or property damage.  
Remember to give due consideration to safety when making your circuit designs, with appropriate  
measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material or  
(iii) prevention against any malfunction or mishap.  
Notes regarding these materials  
1. These materials are intended as a reference to assist our customers in the selection of the Renesas  
Technology Corporation product best suited to the customer's application; they do not convey any  
license under any intellectual property rights, or any other rights, belonging to Renesas Technology  
Corporation or a third party.  
2. Renesas Technology Corporation assumes no responsibility for any damage, or infringement of any  
third-party's rights, originating in the use of any product data, diagrams, charts, programs,  
algorithms, or circuit application examples contained in these materials.  
3. All information contained in these materials, including product data, diagrams, charts, programs and  
algorithms represents information on products at the time of publication of these materials, and are  
subject to change by Renesas Technology Corporation without notice due to product improvements  
or other reasons. It is therefore recommended that customers contact Renesas Technology  
Corporation or an authorized Renesas Technology Corporation product distributor for the latest  
product information before purchasing a product listed herein.  
The information described here may contain technical inaccuracies or typographical errors.  
Renesas Technology Corporation assumes no responsibility for any damage, liability, or other loss  
rising from these inaccuracies or errors.  
Please also pay attention to information published by Renesas Technology Corporation by various  
means, including the Renesas Technology Corporation Semiconductor home page  
(http://www.renesas.com).  
4. When using any or all of the information contained in these materials, including product data,  
diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total  
system before making a final decision on the applicability of the information and products. Renesas  
Technology Corporation assumes no responsibility for any damage, liability or other loss resulting  
from the information contained herein.  
5. Renesas Technology Corporation semiconductors are not designed or manufactured for use in a  
device or system that is used under circumstances in which human life is potentially at stake.  
Please contact Renesas Technology Corporation or an authorized Renesas Technology Corporation  
product distributor when considering the use of a product contained herein for any specific  
purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace, nuclear,  
or undersea repeater use.  
6. The prior written approval of Renesas Technology Corporation is necessary to reprint or reproduce  
in whole or in part these materials.  
7. If these products or technologies are subject to the Japanese export control restrictions, they must  
be exported under a license from the Japanese government and cannot be imported into a country  
other than the approved destination.  
Any diversion or reexport contrary to the export control laws and regulations of Japan and/or the  
country of destination is prohibited.  
8. Please contact Renesas Technology Corporation for further details on these materials or the  
products contained therein.  
REJ05B0272-0200Z/Rev.2.00  
July 2004  
Page 21 of 21  

相关型号:

R8C-AN1P2B

Chip LED with Right Angle Lens
EVERLIGHT

R8C-MS

Sample Program: Musical Scales
RENESAS

R8C/10

SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
RENESAS

R8C/11

SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
RENESAS

R8C/12

SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
RENESAS

R8C/13

SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
RENESAS

R8C/14

16-BIT SINGLE-CHIP MICROCOMPUTER M16C FAMILY / R8C/Tiny SERIES
RENESAS

R8C/15

16-BIT SINGLE-CHIP MICROCOMPUTER M16C FAMILY / R8C/Tiny SERIES
RENESAS

R8C/16

16-BIT SINGLE-CHIP MICROCOMPUTER M16C FAMILY / R8C/Tiny SERIES
RENESAS

R8C/17

16-BIT SINGLE-CHIP MICROCOMPUTER M16C FAMILY / R8C/Tiny SERIES
RENESAS

R8C/18

SINGLE-CHIP 16-BIT CMOS MCU
RENESAS

R8C/19

SINGLE-CHIP 16-BIT CMOS MCU
RENESAS