Renesas ERJ-1TRQJ6R8U Sample program (remote control transmission/reception) Datasheet

Application Notes
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
1.
Summary
This sample program performs remote control transmission/reception by using the Renesas Starter Kit for M16C/26A
(R0K33026AS000BE).
Receiver
Received data
Transmitter
Transmitted data
The extension board used here is a product
from PI System Co., Ltd.
2.
Introduction
The example described in this document applies to the microcomputers listed below:
Microcomputers: M16C26A
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 circuit diagram on page
15 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.)
REJ05B0814-0110 Rev.1.10
2007.12
Page 1 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
3.
Port Arrangement
The key matrix, infrared-ray transmitter/receiver and the buzzer are the facilities mounted on an extension board for the Renesas Starter
Kit. To use these facilities, connect an extension board to the Starter Kit.
LCD
keymatrix
P74
P91
LCD E
P75
P90
LCD R
P63
LCD D7
P62
LCD D6
P61
LCD D5
P60
LCD D4
P76
P77
P104
I R - T R A N S
R C V
-
-
-
-
P105
P106
P80/TA4OUT
P107
P82/INT0
Xin
10MHz
M30260F8AGP
4.
Remote Control Specification
4.1 Remote Control Format
10ms
10ms
Data section
Leader section
100ms
D0
D1
D2
D3
D4
D5
Remote control data
D6
D7
D0
D1
D2
D3
D4
D5
D6
D7
Inverted remote control data
Data section
Data “0”
1ms
1ms
Data “1”
1ms
3ms
Per-bit waveform
REJ05B0814-0110 Rev.1.10
2007.12
Page 2 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
4.2 Determination of the Leader and Data Sections
When the received waveform falls within one of the ranges shown below, it is determined to be a leader or a data section.
Leader section
Leader low-level
duration (10 ms)
8ms - 12ms
Leader pulse width (20 ms)
18ms - 22ms
Data section
Data “1”
(4ms)
3.0ms - 5.0ms
Data “0”
(2ms)
1.0ms - 3.0ms
4.3 Carrier Frequency
38.46kHz
13us
13us
26us
REJ05B0814-0110 Rev.1.10
2007.12
Page 3 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
5.
Operational Outline
<Remote control transmission>
Each time a switch is depressed, the buzzer is sounded and remote control code is transmitted from the infrared LED.
<Remote control reception>
The transmitted code is received in the remote control photodetector, and the received data is shown on liquid crystal display.
Liquid crystal display (LCD)
Liquid crystal display (LCD)
IR-TRAN
RCV----
Infrared LED
IR-TRAN
R C V - - 03
Remote control
photodetector
M16C26A
M16C26A
Code: 00H
Remote control transmission
Remote control reception
The operation described above is accomplished using the following microcomputer facilities:
• 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, key scan and LCD display management are performed using this timer.
• Timer A4 (timer mode, carrier output)
This timer counts 26 microseconds using the main clock of the microcomputer as the count source.
It generates a carrier (frequency 38.46 kHz) that is output during transmission.
• Timer B0 (timer mode, remote control transmission “500 µs”)
This timer counts 500 microseconds using the main clock of the microcomputer as the count source.
It turns carrier output on and off in a 500 microsecond cycle to generate a remote control transmission waveform.
• Timer B2 (timer mode, remote control reception “250 µs”)
This timer counts 250 microseconds using the main clock of the microcomputer as the count source.
It generates remote control receive data from the port input level in a 250 microsecond cycle.
• Timer A1 (pulse modulation mode, buzzer output)
This timer outputs a waveform with different high and low pulse widths using the main clock of the microcomputer as the count source.
It is used to sound a buzzer each time a key is touched.
REJ05B0814-0110 Rev.1.10
2007.12
Page 4 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
6.
Operational Specification
<Remote control transmission>
When a switch is depressed, the remote control code (hex code) corresponding to the switch and the inverted data (hex code) of the remote
control code are transmitted. While a switch is held down, data is transmitted successively at 100 millisecond intervals.
Note: In this program, pressing two or more switches at the same time has no effect (i.e., ignored).
<Remote control reception>
(1) Immediately after the reset switch is depressed, the LCD
shows “-----.”
(1) Reset switch depressed
(2) While remote control code is being received, the LCD shows
the received code.
* If the length of reception period is less than or equal to 500 ms,
the received code is displayed for 500 ms.
I R - T R A N S
R C V
-
-
-
-
(2) Reception underway
(e.g., SW3 held down)
I R - T R A N S
R C V
0 1- F E
(3) 500 ms after reception
I R - T R A N S
R C V
REJ05B0814-0110 Rev.1.10
2007.12
-
-
-
-
Page 5 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
7.
Definition of the RSK Functionality and the RSK_LIB APIs and Common Functions Used by
Remote Control Transmission/Reception
7.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. */
//#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
//#define _OPTION_USE_SW
//#define _OPTION_USE_LED
//#define _OPTION_USE_IO
Individual definition of each selected functionality
#if defined _USE_KEY
/* A key matrix continues pushing and existence is defined.*/
/*When not using
-USE_KEY_CONTINU is made a comment. */
#define _USE_KEY_CONTINU
#if defined _USE_KEY_CONTINU
#define _CONTINU_SW1 _KEY_CONTEINU_ON
#define _CONTINU_SW2 _KEY_CONTEINU_ON
#define _CONTINU_SW3 _KEY_CONTEINU_ON
#define _CONTINU_SW4 _KEY_CONTEINU_ON
#define _CONTINU_SW5 _KEY_CONTEINU_ON
#define _CONTINU_SW6 _KEY_CONTEINU_ON
#define _CONTINU_SW7 _KEY_CONTEINU_ON
#define _CONTINU_SW8 _KEY_CONTEINU_ON
#define _CONTINU_SW9 _KEY_CONTEINU_ON
#define _CONTINU_SW10 _KEY_CONTEINU_ON
#define _CONTINU_SW11 _KEY_CONTEINU_ON
#define _CONTINU_SW12 _KEY_CONTEINU_ON
#define _CONTINU_SW13 _KEY_CONTEINU_ON
#define _CONTINU_SW14 _KEY_CONTEINU_ON
#define _CONTINU_SW15 _KEY_CONTEINU_ON
#define _CONTINU_SW16 _KEY_CONTEINU_ON
#else
REJ05B0814-0110 Rev.1.10
2007.12
Continuous key depressions are accepted.
Page 6 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
7.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_Get_Key( int *Inkey, int *ERcode );
ApiStatusType RL_Getc_Ir( int *IrCode, int *ERcode );
ApiStatusType RL_Putc_Ir( int IrCode, int *ERcode );
ApiStatusType RL_Start_Buzzer( char freqNo, int *ERcode );
ApiStatusType RL_Stop_Buzzer( int *ERcode );
ApiStatusType RL_Putc_Lcd( char Ylocation, char outc, int *ERcode );
ApiStatusType RL_Puts_LcdLoc( char Xlocation, char Ylocation, char RvTime, const char far* outc, int
*ERcode );
ApiStatusType RL_Putc_LcdLoc( char Xlocation, char Ylocation, char RvTime, char outc, int *ERcode );
void RL_ErrorHook( int FuncNo, int ErrorNo );
For details about the APIs and common functions used by the sample program (remote control transmission/reception), see the
Renesas Starter Kit Library V.1.00 Reference Manual.
REJ05B0814-0110 Rev.1.10
2007.12
Page 7 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
8.
Flowchart
Remote control
transmission/recept
Clear display on LCD
Show the initial screen
Request timer setup
Start timers
Input keys
Process buzzer
Keys input?
NO
YES
Transmit key code
Check reception
Check reception
REJ05B0814-0110 Rev.1.10
2007.12
Page 8 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
9.
Tutorial
1
Launch the HEW by double-clicking its icon.
2
Change the session name from “default Session” to “SessionM16C_E8_System.”
REJ05B0814-0110 Rev.1.10
2007.12
Page 9 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
3
Select “M30260F8A” for Device.
Select “Download emulator firmware” for Mode.
REJ05B0814-0110 Rev.1.10
2007.12
Page 10 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
Check the box labeled “Power supply is carried out. (MAX 300mA)” and then select “5.0V.”
REJ05B0814-0110 Rev.1.10
2007.12
Page 11 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
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.
REJ05B0814-0110 Rev.1.10
2007.12
Page 12 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
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.
REJ05B0814-0110 Rev.1.10
2007.12
Page 13 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
6
7
Click “Start after Reset” to start program execution.
Please do "Cancellation" when "The file is opened" window opens.
REJ05B0814-0110 Rev.1.10
2007.12
Page 14 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
10. Circuit Diagram
11. Part List
Part name
Part No.
Q’ty
Manufacturer
Type number
Remote control
U1
1
SHARP
GP1UM281YK
Value
Remark
38kHz
photodetector
Infrared LED
LED1
1
Panasonic
LNA2801L
Transistor
Q1
1
ROHM
2SD1898T100Q
Tact switch
SW1 -
16
OMRON
B3FS-1000P
4
ROHM
1SS355TE-17
1A/0.5W
SW16
Switching diode
D2〜D5
Electrolytic capacitor
C1
1
Panasonic
ECE-V1HS010SR
1uF/50V
Chip
resistor
R1
1
ROHM
MCR10EZHF470
47
1/8W, 1%(5% also acceptable)
Chip
resistor
R2
1
ROHM
MCR10EZHF561
560
1/8W, 1%(5% also acceptable)
Chip
resistor
R5
1
Panasonic
ERJ-1TRQJ6R8U
6.8
1W,5%
REJ05B0814-0110 Rev.1.10
2007.12
Page 15 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
12.
Web Sitet
Renesas Technology Web site
http://www.renesas.com/
REJ05B0814-0110 Rev.1.10
2007.12
Page 16 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
Revision History
Content of revision
Rev.
Date of issue
1.00
2006.06.30
-
First revision issued
1.10
2007.12.03
-
RSK_LIB APIs supported
REJ05B0814-0110 Rev.1.10
Page
Points
2007.12
Page 17 of 18
M16C/26A Group
Sample Program (Remote Control Transmission/Reception)
REJ05B0814-0110 Rev.1.10
2007.12
Page 18 of 18
Similar pages