M16C26A-V RENESAS | Alldatasheet
Document overview
- Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
- PDF pages: 15
Technical content
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 1 of 15 Application Notes M16C/26A Group Sample Program (V oltmeter) 1. Summary This sample program provides the functionality of a voltmeter by using the Renesas Starter Kit for M16C/26A (R0K33026AS000BE). 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 example circuit. 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.) Turning the potentiometer changes the voltage
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 2 of 15 M16C/26A Group Sample Program (V oltmeter) 3. Port Arrangement 4. Operational Outline A voltmeter is displayed on liquid crystal display. Turning the variable resistor (R9) mounted on the board clockwise lowers the voltage, and turning it counterclockwise raises the voltage. 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, LCD display management and AD input are performed using this timer.
- AD24 (single-shot mode, voltage measurement) Analog voltages are converted to digital data using the main clock of the microcomputer as a conversion clock. More specifically, the analog voltages output from the variable resistor (R9) are A/D converted. . 0 0 0 0 v o l m e t e r V 10MHz LCD P93 Xin P60 P61 P62 P63 P90 P91 LCD E LCD RS LCD D7 LCD D6 LCD D5 LCD D4 M30260F8AGP VR M16C26A Liquid crystal display 7PMNFUFS SW2 SW1/ BOOT M16C26A Liquid crystal display 7PMNFUFS SW3R9 M16C26A Liquid crystal display 7PMNFUFS Turning R9 counterclockwise lowers the voltage displayed on LCD. raises the voltage displayed on LCD. Turning R9 clockwise SW2 SW1/ BOOTSW3R9 SW2 SW1/ BOOTSW3R9
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 3 of 15 M16C/26A Group Sample Program (V oltmeter) 5. Operational Specification (1) Immediately after the reset switch is depressed, the LCD shows “0.000V” until an AD value is fixed. (2) Then the LCD shows the input voltage from the variable resistor (R9). * The AD values are set by calling the common function “AD average” (RL_AdVeraging). Within the function, a value is sampled 6 times, and the sampled values except the maximum and minimum values are averaged, the result of which is returned. This average value is acquired 8 times, the average of which is made a fixed value. (1) Reset start . 0 0 0 0 V (2) VR (variable resistor) . 5 2 0 0 V . 0 5 0 0 V v o l m e t e r v o l m e t e r v o l m e t e r
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 4 of 15 M16C/26A Group Sample Program (V oltmeter) 6. Definition of the RSK Functionality and the RSK_LIB APIs and Common Functions Used by Voltmeter
6.1 Definition of the RSK Functionality
RSKdefine.h file In this application, the following functionalities (those shown in red) are set. Individual definition of each selected functionality The boot information on CPU is defined U s u a l l y , t his 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 wh ich 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 #if defined _OPTION_USE_AD /* Define Illumimeter Adc */ //#define _OPTION_USE_AD0 / * D e f i n e V r A d c * / #define _OPTION_USE_AD24 #endif Potentiometer AD
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 5 of 15 M16C/26A Group Sample Program (V oltmeter)
6.2 APIs and Common Functions Used
ApiStatusType RL_Putc_Lcd( char Ylocation, char outc, int *ERcode ); *ERcode ); ApiStatusType RL_Putc_LcdLoc( char Xlocation, char Ylocation, char RvTime, char outc, int *ERcode ); ApiStatusType RL_Puts_LcdLoc( char Xlocation, char Ylocation, char RvTime, const char far* outc, int *ERcode ); ApiStatusType RL_Start_Adc( int AdIdentfier, int *ERcode ); int RL_AdAveraging( int AdLogicalNo, int *AdAverage, int *ERcode ); void RL_ErrorHook( int FuncNo, int ErrorNo ); For details about the APIs and common functions used by the sample program (voltmeter), see the Renesas Starter Kit Library V.1.00 Reference Manual.
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 6 of 15 M16C/26A Group Sample Program (V oltmeter) 7. Flowchart Voltmeter Clear display on LCD Show the initial screen Measure potentiometer Process measured value display Request AD start Measured 8 times? NO YES
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 7 of 15 M16C/26A Group Sample Program (V oltmeter) 8. Tutorial 1 Launch the HEW by double-clicking its icon. 2 Change the session name from “default Session” to “SessionM16C_E8_System.”
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 8 of 15 M16C/26A Group Sample Program (V oltmeter) 3 Select “M30260F8A” for Device. Select “Download emulator firmware” for Mode.
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 9 of 15 M16C/26A Group Sample Program (V oltmeter) Check the box labeled “Power supply is carried out. (MAX 300mA)” and then select “5.0V.”
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 10 of 15 M16C/26A Group Sample Program (V oltmeter) 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.
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 11 of 15 M16C/26A Group Sample Program (V oltmeter) 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.
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 12 of 15 M16C/26A Group Sample Program (V oltmeter) 6 Click “Start after Reset” to start program execution. 7 Please do "Cancellation" when "The file is opened" window opens.
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 13 of 15 M16C/26A Group Sample Program (V oltmeter) 9. Web Sitet Renesas Technology Web site http://www.renesas.com/
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 14 of 15 M16C/26A Group Sample Program (V oltmeter)
Revision History
Content of revision Rev. Date of issue Page Points 1.00 2006.06.30 - First revision issued 1.10 2007.12.03 - RSK_LIB APIs supported
ç REJ05B0815-0110 Rev.1.10 2007.12 Page 15 of 15 M16C/26A Group Sample Program (V oltmeter)