Home
Renesas Starter Kit for RX113 Code Generator Tutorial Manual
Contents
1. R20UT3254EG0101 Rev 1 01 AS Page 8 of 38 Mar 03 2015 RENES RSKRX113 3 Project Creation with CS4 3 Project Creation with CS 3 1 Introduction In this section the user will be guided through the steps required to create a new C project for the RX113 microcontroller ready to generate peripheral driver code using Code Generator This project generation step is necessary to create the MCU specific source project and debug files 3 2 Creating the Project To use the program start CS Windows 7 amp Vista Start Menu Start Menu All Programs Renesas Electronics CS4 CS for CC RX RH850 Windows 8 From Apps View click CS for CC RX RH850 icon e CS will show the Start Page Use the Create New Project 1 A ject can b ted GO button to Create a New Project GO A ev iced can alto be cieniad by reusing the file configuration registered to an existing project Onen Fxistinn Proiect e In the Create Project dialog select RX from the Microcontroller pull create Project down Microcontroller RX e n the Using Microcontroller list TEP control scroll down to RX119 and AB Search microcontroller eeo P Sao Tu jj R5F51136AxFP 100pin Ara palas i in dE R5F51136AxLJ 100pin ip size KBytes Vid a ME 15 S S M e Ensure that in the Kind of project pull k i down Empty Application CC RX is FD selected E RSFSTIS
2. End user code Do not edit comment generated here R20UT3254EG0101 Rev 1 01 RENESAS Page 26 of 38 Mar 03 2015 RSKRX113 6 User Code Integration Insert the following between the user code delimiter comments at the end of the file Start user code for adding Do not edit comment generated here J EEEE E AA AAA e oe ko e o le op dob E E Eak delebo e dede o polo de spo oe ooo do dopo epe kkk kk E Function Name R SCI1 AsyncTransmit Description This function sends SCI1 data and waits for the transmit end flag Arguments tx buf transfer buffer pointer tx num buffer size Return Value status MD OK or MD ARGERROR ejokelokejokekeelelekelekelekejelelelelelekelelelekelekelekelekeleieleleleielelelelekelekelekelelelelekelekeleleekelekelekereielelelelekerekejeleleieieiek MD STATUS R SCI1 AsyncTransmit uint8 t const tx buf const uint16 t tx num 1 MD STATUS status MD OK clear the flag before initiating a new transmission sci1 txdone FALSE Send the data using the API status R SCI1 Serial Send tx buf tx num Wait for the transmit end flag while FALSE sci1 txdone Wait return status RR A A A A o A A A k okok ok okok okok ok k k lll le ok k ok ok ll K le ld A ok k ok ok okok kok ok okok okok koko k ll K oko kk okok ll ok End of function R_SCI1_AsyncTransmit N End user code Do not edit comment generated here 6 4 6 r cg sci h C
3. Text Edit added by clicking the button and pasting the following text into the dialog D R D 1 R 1 D 2 R 2 This instructs the linker to assign RAM rather than ROM addresses to initialised C variables Build Mode Creation and Configuration Debug e From the Build toolbar menu Build Mode Settings select Build Mode Settings SO ele b l Debug AppitoAl e Click on DefaultBuild entry in eram a the Build mode list Duplicate e Click Duplicate and in the Delete resulting Character String Input dialog enter Debug for the Henano name of the duplicate build mode Hb e Click Close L i e n the main CC RX Property window under the Common A CE RX Property Options tab click on the line Build Mod containing Build Mode click the 3 Tem Debug pull down arrow and select Tm Debug from the pull down PICZPID gt Output File Type andPath R20UT3254EG0101 Rev 1 01 RENESAS Page 20 of 38 Mar 03 2015 RSKRX113 In the Frequently Used Options for Compile group select the Optimization Level option and select 0 from the pull down This has now created a Debug build mode with no code optimisation This Build Mode will be used throughout this tutorial to build and debug the project 4 Frequently Used Options for Assem
4. PortD Por PonF PonH Pons P30 Unused O In P Out CMOS output P31 Unused O ln Out CMOS output P32 D Unused Dut E Pul up CMOS output P35 Unused In Figure 4 4 Port 3 Configuration Port Portl Port2 Porta Port4 Port5 Port9 Port PortB Ponc PortD PortE PortF Por Pou PJO 5 Unused 5 Out E Pull up PJ2 Unused In Out PJ3 Unused gt In Out CMOS output PJG Unused 5 In Dut PU Unused In Out Figure 4 5 Port J Configuration R20UT3254EG0101 Rev 1 01 EN ESAS Page 14 of 38 Mar 03 2015 RSKRX113 4 Code Generation Using the CS plug in 4 4 3 Serial Communications Interface This peripheral is configured to use SCI1 This channel of the SCI is connected to the USB to serial converter and allows the application to send data to the terminal program running on the PC Double click on the Serial Communications Interface entry in the Code Generator Peripheral Functions list Configuration is required only SC1 which is selected from the tabs at the top of the Peripheral Functions window Configure the General setting and Setting sub tabs as shown in Figure 4 6 SCI1 General Setting tab amp Figure 4 7 SCI1 Setting tab This will configure the SCI1 channel to use asynchronous Tx Rx using 8 data bits No parity 1 Stop bit at a rate of 19200 baud Proceed to the next section to configure the 12 Bit A D Converter s
5. Assumes the boundary alignment value for str Mo unpack Enables C exceptional handling function try No noexception Enables the C exceptional handling function Nof rtti off General registers used only in fast interrupt fun None fint register O Branch width size Compiles within 24 bits branch 24 Base register for ROM None Base register for RAM None Address value of base register that sets the ad F 00000000 Register of base register that sets the address None Avoids a problem specific to the CPU type No Saves and restores ACC using the interrupt fun No F0 amar Build mode Selects the build mode name to be used during build C Language Select the Compile Options tab at the bottom of the properties window pane Under Language of the C source file select C99 lang c99 as shown opposite Language of the C source file Language of the C source file Additional include paths gt System include paths C99 lang c99 Linker Section Mapping e Select the Link Options tab bottom of the window pane Under Section ROM to RAM mapped section add at the properties the three mappings shown opposite PE ROM to RAM mapped section OM to RAM mapped section 3 0 D 1 D D 1 R 2 2 R20UT3254EG0101 Rev 1 01 Mar 03 2015 TENESAS Page 19 of 38 RSKRX113 5 Project Settings These settings are easily
6. 4 Code Generation Using the CS plug in mr i VOC setling 2 7 V VEC lt 36 v 24 VCC 27 V O 18 Y VCC 24 V Main clock oscilsto and SSI clock SSISCK setting 7 Operation Main clock oscillation source Resonalo Frequency 16 MHz Oscilator wat tme 32768 cycles 98192 lus Dscila on stop detection function Disabled PLL crout setting Frequency x2 Y MHz Subrelock osclistos and RTC RTCSCLK setting Sub clock oscilator dive capacity Frequency 32 768 kHz High speed clock oscillator HOCO setting Operation Frequency 32 MHz Oscilator was time 266 cycle 1665 lus Note When oscilator wal imo of 138 cycles is selected the HOCO frequency accuracy may not be guaranteed See the device users manual for detalis Low speed clock oscilator LOCO setting Frequency la MHz System chek setting System clock ICLK x1 32 MHz Peripheral module clock PCLKB x1 3 MHz Peripheral module clock foe ADC PCLKD x1 32 MHz Flash IF clock FCLK x1 3 MHz IwDT dedcated low speed clock oscilator WDTLOCO setting le Opesation 1 Frequency 15 kHz USB dedicated clock UCLK setting Operation UCLK clock sowce USB dedicated PLL clock Frequency x3 48 MHz LCD source clock LCDSRCCLK setting equency Sub clock oscillator 0022768 MHz CLKOUT pin setting Operation P15 Dock output source Main clock osc
7. RSK is not guaranteed to be error free and the entire risk as to the results and performance of the RSK is assumed by the User The RSK is provided by Renesas on an as is basis without warranty of any kind whether express or implied including but not limited to the implied warranties of satisfactory quality fitness for a particular purpose title and non infringement of intellectual property rights with regard to the RSK Renesas expressly disclaims all such warranties Renesas or its affiliates shall in no event be liable for any loss of profit loss of data loss of contract loss of business damage to reputation or goodwill any economic loss any reprogramming or recall costs whether the foregoing losses are direct or indirect nor shall Renesas or its affiliates be liable for any other direct or indirect special incidental or consequential damages arising out of or in relation to the use of this RSK even if Renesas or its affiliates have been advised of the possibility of such damages Precautions The following precautions should be observed when operating any RSK product This Renesas Starter Kit is only intended for use in a laboratory environment under ambient temperature and humidity conditions A safe separation distance should be used between this and any sensitive equipment Its use outside the laboratory classroom study area or similar such area invalidates conformity with the protection requirements of the Electrom
8. Use This Manual 1 Purpose and Target Readers This manual is designed to provide the user with an understanding of how to use Code Generator for RX together with the CS IDE to create a working project for the RSK platform It is intended for users designing sample code on the RSK platform using the many different incorporated peripheral devices The manual comprises of step by step instructions to generate code and import it into CS but does not intend to be a complete guide to software development on the RSK platform Further details regarding operating the RX113 microcontroller may be found in the Hardware Manual and within the provided sample code Particular attention should be paid to the precautionary notes when using the manual These notes occur within the body of the text at the end of each section and in the Usage Notes section The revision history summarizes the locations of revisions and additions It does not list all revisions Refer to the text of the manual for details The following documents apply to the RX113 Group Make sure to refer to the latest versions of these documents The newest versions of the documents listed may be obtained from the Renesas Electronics Web site Document Type Description Document Title Document No User s Manual Describes the technical details of the RSK hardware RSKRX113 User s R20UT2756EG Manual Tutorial Manual Provides a guide to setting up RSK environm
9. an ADC conversion adc result get adc Display the result on the LCD led display adc adc result Display count on LEDs led display count adc count Send the result to SCII UART uart display adc adc count adc result Increment the adc count and check roll over if 16 adc count adc count 0 Reset the flag g adc trigger FALSE SW3 is directly wired into the ADTRGOn pin so will cause the conversion and interrupt else if TRUE g adc complete Get the result of the ADC conversion R SI2AD Get ValueResult ADCHANNELO amp adc result Display the result on the LCD lcd display adc adc result Display count on LEDs led display count adc count Send the result to the UART uart display adc adc count adc result Increment the adc count and check roll over if 16 adc count adc_count 0 Reset the flag g_adc_complete FALSE else do nothing End user code Do not edit comment generated here Insert the following in to the function void R MAIN UserInit void Start user code Do not edit comment generated here Initialise the LCD for the RSK LCD APP V2 display board R LCD Create R LCD Start Start the ADC R S12AD Start End user code Do not edit comment generated here 6 User Code Integration R20UT3254
10. declaration for get adc static uint16 t get adc void Prototype declaration for lcd display adc static void lcd display adc const uint16 t adc result Prototype declaration for uart display adc static void uart display adc const uint8 t adc count const uint16 t adc result Variable to store the ADC conversion count for user display static uint8 t adc count 0 Prototype declaration for led display count static void led display count const uint8 t count Variable for flagging user requested ADC conversion volatile uint8 t g adc trigger FALSE End user code Do not edit comment generated here Insert the following in to the function void main void Note this overwrites the while 1U loop included by Code Generator Start user code Do not edit comment generated here Display Project Title on LCD R LCD DisplayPanelString PANEL LCD LINEI uint8 t TUTOR Set up SCII receive buffer and callback function R SCII Serial Receive uint8 t amp g rx char 1 Enable SCII operations R SCII Start Display Welcome Banner on Serial Port R SCII AsyncTransmit welcome banner sizeof welcome banner R20UT3254EG0101 Rev 1 01 RENESAS Page 28 of 38 Mar 03 2015 RSKRX113 while 1U uintl6 t adc result Tf the user has requested ADC sample via the serial port if TRUE g adc trigger Call the function to perform
11. h hy r cg vecth hy r cg macrodriver h r cg userdefine h ny r cg cgc h p r cg port h KJ r cg sci h E h r cg sl2ad h Figure 4 11 Generated Code in Project tree R20UT3254EG0101 Rev 1 01 Mar 03 2015 RTENESAS Page 18 of 38 RSKRX113 5 Project Settings 5 Project Settings This section covers changes to the CS blank project to allow it to run on the RSK e ln the Project Tree pane click on CC RX Build Tool The build properties will appear in the main window e CS creates a single build called Default Build for the project This has optimisation configuration standard code turned on by default level 2 CC RX Property 4 BuildMode Build mode DefaultBuild 4 CPU Instruction set architecture RXvl architecture isa rav1 Uses floating point operation instructions Nof nofpu Endian type for data Little endian data endian little Rounding method for floating point constant op round to nearest round nearest Handling of denormalized numbers in floating p Handles as zeros denormalize off Precision of the double type and long double typ Handles in single precision dbl size Replaces the int type with the short type No Sign of the char type Handles as unsigned char unsigned Sign of the bit field type Handles as unsigned unsigned_bitfie Selects the enumeration type size automatically No Order of bit field members Allocates from right bit order right
12. ok k ok ok Sk ok ok ok ok ok ok ok ok ok ok ok ok okok okok okok okok okok okok okok okok ok okok okok ok okok okok okok okok k k k k k k k k BORK okok okok okok okok ok ok ok ok okok ok ok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok Sk kc ke ke okok kk kk okok kk kk okok okok okok x Function Name led display count Description Argument Return value Converts count to binary and displays on 4 LEDS0 3 uint8 t count none FAK KK A RR KK ko RR ROTOR ko k Ck XX KKK Ak K RR RRA RRA RAR RR ARA kk kk static void led display count const uint8 t count Set LEDO LED1 LED2 LED3 lower nibble of count parameter 0x01 LED ON LED OFF 0x02 LED ON LED OFF 0x04 LED ON LED OFF 0x08 LED ON LED OFF LEDs according to uint8 t count amp uint8 t count amp uint8 t count amp uint8 t count amp BORK IKK IKK A IKK AK IKK A IKK IK A IK IK IK AA End of function led_display_count FER A okok kok kok kok kk ok okok kok okok kok kk k kok kok kk okok okok ke kk ok ok okok okok okok ke kk k k kk k kk k k kk I I I ke ke ke ke End user code Do not edit comment generated here R20UT3254EG0101 Rev 1 01 Mar 03 2015 RENESAS Page 31 of 38 RSKRX113 7 Project Build and Debugger Configuration 7 Project Build and Debugger Configuration Select Build Project from the
13. radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or systems manufactured by you 8 Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations 9 Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations You should not use Renesas Electronics products or technology described in this document for any purpose relating to military applications or us
14. 0 625 us Actual value 0 625 ANOO8 ANO15 conversion time setting Input sampling time 0 625 us Actual value 0 625 ANO21 conversion time setting Input sampling time D 625 Li us Actual value 0 625 Conversion time setting Total conversion time Group A 8 25 us Total conversion time Group B 0 094 lus Interrupt setting V Enable AD conversion end interrupt S12ADIO Priority Level 15 highest v Enable AD conversion end interrupt for group B GBADI Priority Level 15 highest Figure 4 9 A D Converter Setting tab RTENESAS R20UT3254EG0101 Rev 1 01 Mar 03 2015 Page 17 of 38 RSKRX113 4 Code Generation Using the CS plug in 4 4 5 Generating the code Peripheral function configuration is now complete Click Generate Code button located at the top right of the Peripheral Function tab The Console pane should report The operation of generating file was successful as shown Figure 4 10 below Dutput MO409002 The generating source folder is C Workspace CG_Tutorial MO409001 The following files were generated MO409000 cg srcir cg main c was generated MO0409000 cg srcir cg dbsct c was generated MO409000 cg srcir cy intprg c was generated MO409000 cg srcir cg resetprg c was generated MO409000 cg srcir cg sbrk c was generated MO409000 cg srcir cq vecttbl c was generated MO409000 cg srcir cg sbrk h was generated MO409000 cg srcir cy stacksct h was g
15. 2000000 from the emulator MAX 200mA to Yes e All other settings can remain at their defaults Connect the El to the PC and the RSK El A connector m Ensure the LCD APP V2 display is connected to JA4 R20UT3254EG0101 Rev 1 01 Mar 03 2015 2TENESAS Page 32 of 38 RSKRX113 7 Project Build and Debugger Configuration 7 1 Running the Tutorial Before launching the tutorial connect the RSK RL78G1C USB port to a USB port on a PC If this is the first time the RSK has been connected to the PC then a device driver will be installed automatically Open Device Manager the virtual COM port will now appear under Port COM amp LPT as RSK USB Serial Port COMx where x is a number Open a terminal emulation program such as HyperTerminal connecting to COMx with the settings 19200 baud 8 data bits No parity 1 stop bit From the CS Debug menu select Download to start the debug session and download code to the target Once the program has been downloaded onto the RSK device the program can be executed gt Click the Go button or press F5 to begin the program from the current program counter position The program will display RSK RX113 Tutorial Press c or SW3 for ADC Conversion on the serial terminal and TUTOR on the bottom line of the LCD Pressing SW3 or entering the character C in the serial terminal window will trigger an ADC conversion and display the
16. A ee OVA ede Pe ae euge dava ea n DA 23 6 2 EGD file COPY ML E 23 6 3 Including files in the CS Project sssssssseesesseseeesseeenne entente KKK PKP KKK KKK AKA ARK eniin 24 6 4 Adding Code to Generated Files 2 2 eee eee anaana niaaa aaan ea saaana aikaakaan iaa dia 24 6 4 1 r cg userdefine h Code Insertion eene enne nennen K KKK KKK 24 6 4 2 r cg sl2ad c Code Nseries ideae dna 25 6 4 3 r cg s12ad h Code Insertion ener E A 25 6 4 4 r cg sTead user c Code Serio circa etcetera te id e E das 26 6 4 5 r cg sci user c Code InSertiOM oooocoonocccononoccccnononccnnononnnnnononncnnnno nn nnnnnn nn nn nnne K KEE KRK K nnne nnne nis 26 6 4 6 r cgsscili Code Insertion rein dde caida 27 6 4 7 r cg main c Code Insertion ooooonocccononoccconononcnnnnnoncnnnnnonnnnnnnonnnnnnnn a eaa r a 28 7 Project Build and Debugger Configuration ccccceceeeeeeseeeececeeeeeeeeeeeeeeaeeeeeeeeeeeeeeees 32 7 1 Rurining the Tutorial id t PAPO eint 33 8 Additional Information eeseeseeneenneennnknnnnnknnknnnnnnknnknnnknnknnnannknnknnsas 34 LENESAS RSKRX113 R20UT3254EG0101 Rev 1 01 RENESAS STARTER KIT Mar 03 2015 1 Overview 1 1 Purpose This RSK is an evaluation tool for Renesas microcontrollers This manual describes how to use the CS IDE Code Generator plug in to create a working project for the RSK platform 1 2 Features This RSK tutorial guides t
17. Build menu or press F7 CS will build the project with no errors Configure the E1 debugger and board as follows e In the Project Tree pane right click the RX Simulator Debug Tool Select Using Debug Tool gt RX E1 Serial A CG Tutorial Project E R5F51138AxFP Microcontroller P Code Generator Design Tool H A Pin View 3j ku Peripheral Functions W Code Preview A CC RX Build Tool RX Simulator Debug Tool 4 1 r G ote de ee e se ee he OA DISCLAIMER This software No other uses applicable lai THIS SOFTWARE OR STATUTORY i INO eu I Pig File E tl Build tool generated f Code Generator Property Using Debug Tool RX E1 Serial RX E20 Serial BJ r eg main c d m 12 RX Simulator Double click RX U RXEl Serial Property E1 Serial Debug o E riso p Tool to display the 64 debugger tool Size o es ti 4 Clock proper les Main clock source EXTAL Main clock freguency MHz 16 0000 ki Under Glock change Operating frequency MH z the Main clock Allow changing of the clock source on writing internal flash memory No 4 Connection with Emulator freguency MHz to Emulator serial No 16 000 MHz 4 Connection with Target Board i P target from th lator MAX 200m4 Y Under Connection E with Targ et Board Communications method FINE change Power target FINE baud rate bps
18. C 7 A 0 D o 24 NESAS RX113 Group Renesas Starter Kit Code Generator Tutorial Manual For CS RENESAS MCU RX Family RX100 Series All information contained in these materials including products and product specifications represents information on the product at the time of publication and is subject to change by Renesas Electronics Corporation without notice Please review the latest information published by Renesas Electronics Corporation through various means including the Renesas Electronics Corporation website http www renesas com Renesas Electronics www renesas com Rev 1 01 Mar 2015 Notice 1 Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information 2 Renesas Electronics has used reasonable care in preparing the information included in this document but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein 3
19. C had completed a sample g adc complete 1 End user code Do not edit comment generated here 6 4 5 r cg sci user c Code Insertion Open this file by double clicking on the file name in the CS Project Tree window Insert the following between the user code delimiter comments as shown below in the file section designated Global variables and functions Start user code for global Do not edit comment generated here Global used to receive a character from the PC terminal uint8 t g rx char Flag used to control transmission to PC terminal volatile uint8 t g tx flag FALSE Flag used locally to detect transmission complete static volatile uint8 t scil txdone End user code Do not edit comment generated here Insert the following in to the function static void r scil callback transmitend void Start user code Do not edit comment generated here Scil txdone TRUE End user code Do not edit comment generated here Insert the following in to the function static void r scii callback receiveend void Start user code Do not edit comment generated here Check the contents of g rx char g rx char g rx char 8 OxDF Ensure ASCII char is in upper case Check for the c trigger command if C g rx char g adc trigger TRUE Set up SCI1 receive buffer and callback function again R SCI1 Serial Receive uint8 t amp g rx char 1
20. EG0101 Rev 1 01 Mar 03 2015 RENESAS Page 29 of 38 RSKRX113 6 User Code Integration Insert the following between the user code delimiter comments at the end of the file Start user code for adding Do not edit comment generated here KKK ok Ck kc kc kc kc kc Sk okok okok okok okok okok okok ok ok okok okok okok ke k okok okok ok ok ok ok ke ok ok ok ok ok ok ok ok ok okok okok okok okok ok ok ok okok okok ke e e Function Name get adc Description Creates a ADC12 Software trigger and returns the ADC result once the ADC conversion is complete Argument none Return value uintl16 t ADC sample value kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk static uintl6 t get adc void A variable to retrieve the ADC result uinti6 t adc result Start a conversion R S12AD SWTriggerStart Wait for the ADC conversion to complete while FALSE g adc complete Wait Stop conversion R S12AD SWTriggerStop x Clear ADC flag g adc complete FALSE R S12AD Get ValueResult ADCHANNELO amp adc result Set AD conversion start trigger source back to ADTRGOn pin R S12AD Start return adc result S EEK Kk kkk k k kk ck ck k k k k k k k k kk k k k k k k k ck ckckckck kk ck ck ck ck ck kckckckckckckckck kk kk ck ck ck ck kckckckckck ck k ck k ck ck ck ck ck k ck k End of function get adc o e kok Ck kk ok ok ok ok ok ok ko ke ok o
21. RSK RX113 Code Generator Tutorial Manual CS Rev Date Description Page Summary 1 00 Dec 15 2014 First Edition issued 1 01 Mar 03 2015 13 10 Updated Figure 4 2 Figure 4 9 19 31 Added a frame Renesas Starter Kit Manual Code Generator Tutorial Manual Publication Date Rev 1 01 Mar 03 2015 Published by Renesas Electronics Corporation LENESAS SALES OFFICES Renesas Electronics Corporation http www renesas com Refer to http www renesas com for the latest and detailed information Renesas Electronics America Inc 2801 Scott Boulevard Santa Clara CA 95050 2549 U S A Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 1101 Nicholson Road Newmarket Ontario L3Y 9C3 Canada Tel 1 905 898 5441 Fax 1 905 898 3220 Renesas Electronics Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel 44 1628 585 100 Fax 44 1628 585 900 Renesas Electronics Europe GmbH Arcadiastrasse 10 40472 D sseldorf Germany Tel 49 211 6503 0 Fax 49 211 6503 1327 Renesas Electronics China Co Ltd Room 1709 Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100191 P R China Tel 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd Unit 301 Tower A Central Towers 555 Langao Road Putuo District Shanghai P R China 200333 Tel 86 21 2226 0888 Fax 86 21 2226 0999 Renesas El
22. Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others 4 You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from such alteration modification copy or otherwise misappropriation of Renesas Electronics product 5 Renesas Electronics products are classified according to the following two quality grades Standard and High Quality The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below Standard Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots etc High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster Systems anticrime systems and safety equipment etc Renesas Electronics products are neither intended nor authorized for
23. SAXLA 100pin A TL dik Dn e Choose an appropriate name and Kind of project Empty Application CC RX location for the project then click p cc re ate Project name CG Tutorial li a Place CAW Note this tutorial assumes the project ka Bromo is named and located at the place ADH shown opposite C Workspace CG_Tutorial CG_Tutorial mtpj a 78 S e If the folder entered cannot be found a p ios fo Me concen ofon emen prose lo lle row proc i i 1 Project to be passed j Browse Question dialogue with be displayed li click Yes Copy composition files in the diverted project folder to a new project folder i Cies ems ee e CS will create the blank project with the standard project tree A Code E Property Generator node may also be shown if 808 A qe previously enabled Tee Project FE FE R5F51138AxFP Microcontroller CC RX Build Tool Absolute path RX Simulator Debug Tool Notes I File R20UT3254EG0101 Rev 1 01 RENESAS Page 9 of 38 Mar 03 2015 RSKRX113 4 Code Generation Using the CS plug in 4 Code Generation Using the CS plug in 4 1 Introduction Code Generator is an CS plug in GUI tool for generating template C source code for the RX113 When using Code Generator the user is able to configure various MCU features and operating parameters using intuitive GUI controls bypassing the need in most cases to ref
24. a source list file Nof nolistfile The Debug build will be used to the remainder of this tutorial Reset the build mode back to Debug using the Build Mode pull down control From the menus select File gt Save All to save all project settings al Save All Ctrl Shift A R20UT3254EG0101 Rev 1 01 Mar 03 2015 2TENESAS Page 21 of 38 RSKRX113 5 1 Adding Project Folders 5 Project Settings e Before new source files are added to the project we will create two additional folders in the CS Project Tree e n the Project Tree pane right click the CG Tutorial project name and select Add Add New Category Property UR CG Tutorial Property 4 File Sil Peripheral Functions f rcg maine f rec 2 A E Bg RS Tutorial Project R5F511 Dr Build CG Tutorial B Code 6 F ebuild CG Tutorial aq CC RX H epul I utoria i RX Sim L Clean CG Tutorial 3 kil B Open Folder with Explorer El Windows Explorer Menu fS Add Subproject ffs Set CG Tutorial as Active Project em Add New Subproject i Save Project and Development Tools as Package 3 Add File B Paste Ctrl V 39 Add New File de Rename R ge Property e Rename the newly created New P nj r cg port h Category folder to C Source r cg sci h Files By cg s12ad h e Repeat these steps to create a C Source Files new cat
25. agnetic Compatibility Directive and could lead to prosecution The product generates uses and can radiate radio frequency energy and may cause harmful interference to radio communications However there is no guarantee that interference will not occur in a particular installation If this equipment causes harmful interference to radio or television reception which can be determined by turning the equipment off or on you are encouraged to try to correct the interference by one or more of the following measures e ensure attached cables do not lie across the equipment e reorient the receiving antenna e increase the distance between the equipment and the receiver e connect the equipment into an outlet on a circuit different from that which the receiver is connected e power down the equipment when not in use e consult the dealer or an experienced radio TV technician for help NOTE It is recommended that wherever possible shielded interface cables are used The product is potentially susceptible to certain EMC phenomena To mitigate against them it is recommended that the following measures be undertaken e The user is advised that mobile phones should not be used within 10m of the product when in use e The user is advised to take ESD precautions when handling the equipment The Renesas Starter Kit does not represent an ideal reference design for an end product and does not fulfil the regulatory standards for an end product How to
26. ble 5 Project Settings 4 Frequently Used ptions for Compie Additional include paths System include paths Macro definition Dutputs debugging information Y es debug Optimization level O optimize O Outputs additional information for inter modul E 8 Optimization type optimize Outputs a source list file 2 optimize 2 Max optimize max Additional include paths 1 System include paths 0 Macro definition O Build Mode Creation and Configuration Release All of the sample code projects contained in this RSK are configured with three Build modes DefaultBuild Debug and Release Release is created in the same way as above by duplicating Default Build Release build mode leaves code optimisation turned on and removes debug information from the output file To remove debug information from the Release build mode in the CC RX Property window select the Common Options tab at the bottom of the window pane For the Outputs debugging information option select No nodebug CC RX Property 4 BuildMode la Build mode CPU PIC PID Output File Type andPath Frequently Used Options for Compie Additional include paths System include paths Macro definition Outputs debugging information Optimization level Release Additional include paths 1 System include paths 0 Iv Optimization type Outputs
27. cio SCIT Function setting sci2 scis scie scie scis scn2 Setting D Unused D Asynchronous mode Multi processor Transmission D Clock synchronous mode Transmission Smart card interface mode Transmission gt Simple IIC bus D Simple SPI bus Slave transmit receive Pin setting RXD1 5MISO1 SSCL1 P15 TXD1 SMOSI1 SSDA1 P16 Figure 4 6 SCI1 General Setting tab R20UT3254EG0101 Rev 101 RENESAS Page15 of 38 Mar 03 2015 RSKRX113 4 Code Generation Using the CS plug in sols scis scia scie scii2 Start bit edge detection setting General setting 9 Low level on RXD1 pin D Falling edge on RXD1 pin Data length setting 8 bits D 7 bits Parity setting None D Even D Odd Stop bit length setting 1 bit 2 bits Transfer direction setting LSB first D MSB first Transfer rate setting Transfer clock Internal clock P17 Base clock 8 cycles for 1 bit period Bit rate 19200 bps Actual value 19230 76923 Error 0 16026 SCK1 pin function SCK1 is not used Noise filter setting Enable noise filter Noise filter clock Clock signal divided by 1 32000000 Hz Hardware flow control setting None B CTS D RTS CTS1 ATS1 pin Pl4 Data handling setting Transmit data handling Data handled in interrupt service routine Receive data handling Data handled in interrupt service routine Interrupt setting 4 Enable error interrupt ERIT TXI1 TEM RXI1 ERIT prio
28. de E R5F51138AxFP Microcontroller Ee Code Generator Design Tool Dutput folder Pin View File generation control z Peripheral Functions Register files a f Code Preview Report type R20UT3254EG0101 Rev 1 01 Mar 03 2015 CC RX Build Tool RX Simulator Debug Tool 9 File 2TENESAS 4 Product Information Release date Page 10 of 38 RSKRX113 4 Code Generation Using the CS plug in 4 3 Code Generator Tour This section presents a brief tour of Code Generator For further details of the Code Generator paradigm and reference refer to the Application Leading Tool Common Operations manual r20ut2663ej0100 Application Leading Tool is the stand alone version of Code Generator and this manual is applicable to the Code Generator In the Project Tree pane click on the icon next to Code Generator node to expand the list Expand the Peripheral Functions node by clicking on the E next to it Open the Peripheral Function tab by double clicking on the Peripheral Functions name The CS main window will now contain a Peripheral Functions tab with the Initial View as show in Figure 4 1 Mi File Edit View Project Build Debug Tool Window Help Start BB EX iD 2 e A a y E ER DefaukBuild LAO SOON sc E 3239129 ki p Property S Peripheral Functions l Generate Code Won 4a eic UD OA P BTD A RAI lock setting Block diagram E LR CG Tu
29. e by the military including but not limited to the development of weapons of mass destruction When exporting the Renesas Electronics products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations 10 Itis the responsibility of the buyer or distributor of Renesas Electronics products who distributes disposes of or otherwise places the product with a third party to notify such third party in advance of the contents and conditions set forth in this document Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics products 11 This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics 12 Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics 2012 4 Disclaimer By using this Renesas Starter Kit RSK the user accepts the following terms The
30. ectronics Hong Kong Limited Unit 1601 1613 16 F Tower 2 Grand Century Place 193 Prince Edward Road West Mongkok Kowloon Hong Kong Tel 852 2265 6688 Fax 852 2886 9022 9044 Renesas Electronics Taiwan Co Ltd 3F No 363 Fu Shing North Road Taipei 10543 Taiwan Tel 886 2 8175 9600 Fax 886 2 8175 9670 Renesas Electronics Singapore Pte Ltd 80 Bendemeer Road Unit 406 02 Hyflux Innovation Centre Singapore 339949 Tel 65 6213 0200 Fax 65 6213 0300 Renesas Electronics Malaysia Sdn Bhd Unit 906 Block B Menara Amcorp Amcorp Trade Centre No 18 Jin Persiaran Barat 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel 60 3 7955 9390 Fax 60 3 7955 9510 Renesas Electronics Korea Co Ltd F 234 Teheran ro Gangnam Ku Seoul 135 920 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 m 2014 Renesas Electronics Corporation All rights reserved Colophon 3 0 RX113 Group LENESAS Renesas Electronics Corporation R20UT3254EG0101
31. eference voltage Disable Enable Analog input channel setting anyert Group A ANODO ANDOT ANDO2 ANO03 ANOO4 ANDOS ANDOS ANDO ANDO8 ANDOS ANOIO ANOT A ANDI2 ANO13 ANO14 ANDI5S ANO21 Convert Group B Add AD converted value Conversion start trigger setting Conversion start trigger Group B TRGA input capture compare match from MTUO ADTRGOt pin selection Data registers setting P27 Please set MTU AD converted value addition count Data placement Automatic clearing 1 time conversion Right alignment Disable automatic clearing ANODO conversion time setting Input sampling time 7 us Actual value 7 ANODI conversion time setting Input sampling time 0 625 us Actual value 0 625 AN002 conversion time setting Input sampling time 0625 lus Actual value 0 625 ANOO3 conversion time setting Input sampling time D 625 Zi SES us Actual value 0 625 ANOD4 conversion time setting Input sampling time 0625 Ni Y us Actual value 0 625 ANOD5 conversion time setting Input sampling time D 625 y us Actual value 0 625 ANOOS conversion time setting Input sampling time 0 625 us Actual value 0 625 ANOO conversion time setting Input sampling time
32. egory folder for ALI Dependencies Dependencies R20UT3254EG0101 Rev 1 01 EN ESAS Page 22 of 38 Mar 03 2015 RSKRX113 6 User Code Integration 6 User Code Integration At this stage of a typical project development the user would expand on the generated code to create the application required As a demonstration this tutorial will include code lines and files from the complete Tutorial project supplied on the RSK installation DVD When inserting code in Code Generator created files it must be placed in the areas delimited by comments as follows Start user code for xxxxx Do not edit comment generated here End user code Do not edit comment generated here Where xxxx depends on the particular area of code i e function for insertion of user functions and prototypes global for insertion of user global variable declarations or include for insertion of pre processor include directives User code inserted inside these comment delimiters is protected from being overwritten by Code Generator if the user refreshes the Code Generator generated code 6 1 Support file copying RSK support and utility functions are provided in the following files iodefine h r rsk utility c r rsk utility h rskrx113def h Using WindowsTM Explorer locate the Tutorial project folder and copy the files above to the project folder created in section 3 2 this will be CAWorkspaceYCG Tutorial if following the example scree
33. en Folder with Explorer W Add New File e Browse to and select the following files copied in i dn NB os k i El Windows Explorer Menu n Add New Category the section above and click Add i El Remove from Project Shift Del iodefine h 43 Copy Ctrl C r rsk utility h aj paste SUY rskrx113def h a e Rename F2 r lcd appv2 h Property 6 4 Adding Code to Generated Files This section covers inserting code in to the newly created Code Generator files Each subsection is a Code Generated source file that needs to be opened by double clicking on the file name in the CS Project Tree window File gt Code Generator The code from each section should be copied from this document and pasted in to the relevant file at the location indicated 6 4 1 r cg userdefine h Code Insertion Open this file by double clicking on the file name in the CS Project Tree window Insert the following at the end of the file between the user code delimiter comments as shown below Start user code for function Do not edit comment generated here define TRUE 1 define FALSE 0 extern volatile uint8 t g adc trigger End user code Do not edit comment generated here R20UT3254EG0101 Rev 1 01 EN ESAS Page 24 of 38 Mar 03 2015 RSKRX113 6 User Code Integration 6 4 2 r cg s12ad c Code Insertion Open this file by double clicking on the file name in the CS Project Tree window Insert the following at the
34. end of the file between the user code delimiter comments as shown below Start user code for adding Do not edit comment generated here BR KR RR KKK RR KK kkk kkk kkk kkk ckckck ck KKK KK ck ck ck ck ck ck kkk kkk kkk kkk ck ck ck ck ck kk KK kkk kk kkk kk kk k Function Name R S12AD SWTriggerStart Description This function starts the ADO converter Arguments None Return Value None Kk kk oke ok oke ok oke ok kk kc ke oke K ke Sk ke oke ke oke ke Sk ke Sk ke Sk ke Sk KA KX ke oke ok oke ok Sk ke Sk ke kk I oke ok kk kk oke KX ok ke ke ke ke oke ok kc ke ok ke ke ke ke ok ke ke ke e e x void R S12AD SWTriggerStart void S12AD ADCSR BIT ADST 1U BRR KKK KK KR ok ko k kk kk KA kk k k k k k k ke kk kk kk kk AAA End of function R S12AD SWTriggerStart KK kk kk kk Ck oka ok ok ok ok ok ok okok okok ok ok okok ok ok ok okok okok okok ok ok ok okok RRA kk Sk Sk RA KK KARA RARA KK KK A KK BR KKK KKK KK KR KK RK KKK KR KKK AAA Function Name R S12AD SWTriggerStop Description This function stops the ADO converter Arguments None Return Value None Kk oke ok oke ok kk kk Sk k ke oke k ke oke ke oke k k k ke Sk KX ke Sk KA ok Sk ke Sk ke Sk ok Sk ok ok ok oke ok Sk ok ok okok okok okok okok okok okok okok okok okok ke ke ke ke ke ke e ke x kx void R S12AD SWTriggerStop void S12AD ADCSR BIT ADST OU BRK KKK KKK KR KR KKK KK ck ck ck AA End of function R_S12AD_SWTriggerStop KKK KK ok ok ok ok ok okok
35. enerated MO409000 cg srcir cg vect h was generated MO409000 cg srcir cg hardware setup c was generated reg srcir cg macrodriver h was generated reg srcir cg userdefine h was generatea cg srcir cg cgc c was generated reg srcir cg cgc user c was generated reg srcir cg cgc h was generated MO409000 cg srcir cg port c was generated M0409000 cg src r cy port user c was generatea Icy srcir cg port h was generated reg srcir cg sci c was generated rcg srcir cg sci user c was generated reg srcir cg sci h was generated 1cg srcir cg slZad c was generated reg srcir cg slZad user c was generated MO0409000 cg srcXr cg slZad h was generated MO409003 The operation of generating file was successful lzor All Messages Code Generator Figure 4 11 shows the Code Generator Files in the Project Tree pane Figure 4 10 Code generator console In the following sections the CG_Tutorial project will be completed by adding user code into these files and adding new source files to the project j g Build tool generated files o Code Generator r cg main c r cg dbsct c E r eg intprg c i r cg resetprg c r cg sbrk c BJ r cg vecttbl c BJ r cg hardware setup c r cg cgc c r cg cgc user c 1 j r_cg_port c i r cg port user c ej r cg sci c i r Cg sci user c r cg sl2ad c e r_cg_s12ad_user c hy r_cg_sbrk h h r cg stacksct
36. ent RSKRX113 Tutorial R20UT2757EG running sample code and debugging programs Manual Code Generator Provides a guide to code generation and importing RSKRX113 Code R20UT3254EG Tutorial into the CS IDE Generator Tutorial Manual Quick Start Guide Provides simple instructions to setup the RSK and RSKRX113 Quick R20UT2758EG run the first sample on a single A4 sheet Start Guide Schematics Full detail circuit schematics of the RSK RSKRX113 R20UT2755EG Schematics Hardware Manual Provides technical details of the RX113 RX113 Group RO1UH0448EJ microcontroller User s Manual Hardware 2 List of Abbreviations and Acronyms Analog to Digital Converter Application Programming Interface COMmunications port referring to PC serial port Central Processing Unit Digital Versatile Disc Renesas On chip Debugging Emulator Graphical User Interface Integrated Development Environment IRQ Interrupt Request line LCD Liquid Crystal Display LED Light Emitting Diode MCU Micro controller Unit PC Personal Computer Pmod This is a Digilent Pmod Compatible connector Pmod is registered to Digilent Inc Digilent Pmod Interface Specification PLL Phase locked Loop RAM Random Access Memory ROM Read Only Memory RSK Renesas Starter Kit SCI Serial Communications Interface SPI Serial Peripheral Interface UART Universal Asynchronous Receiver Transmitter USB Universal Serial B
37. er to sections of the Hardware Manual By following the steps detailed in this tutorial the user will generate a CS project called CG Tutorial A fully completed Tutorial project is contained on the DVD and may be imported into CS by following the steps in the Quick Start Guide This tutorial is intended as a learning exercise for users who wish to use the Code Generator to generate their own custom projects for CS Once the user has configured the project the Generate Code function is used to generate three code modules for each specific MCU feature selected These code modules are name r cg xxx h T cg XXX C and r cg xxx user c where xxx is a three letter acronym for the relevant MCU feature for example adc Within these code modules the user is free to add custom code to meet their specific requirement Custom code should be added between the following comment delimiters Start user code for adding Do not edit comment generated here End user code Do not edit comment generated here Code Generator will locate these comment delimiters and preserve any custom code inside the delimiters on subsequent code generation operations Any code outside of these comment delimiters will be overwritten on subsequent code generation sessions The CG Tutorial project uses the ADC module with external trigger Serial Communications Interface SCI and LCD Driver These modules are used to perform an A D conversion dis
38. he user through creating a project to evaluate the following features e Project creation with CS e Code Generation using the Code Generator plug in e User circuitry such as switches LEDs and a potentiometer The RSK board contains all the circuitry required for microcontroller operation R20UT3254EG0101 Rev 1 01 AS Page 7 of 38 Mar 03 2015 RENES RSKRX113 2 Introduction 2 Introduction This manual is designed to answer in tutorial form how to use the Code Generator plug in for the RX family together with the CS IDE to create a working project for the RSK platform The tutorials help explain the following e Project generation using the CS e Detailed use of the Code Generator plug in for CS e Integration with custom code e Building and running the project The project generator will create a tutorial project with three selectable build configurations e DefaultBuild is a project with debug support and optimisation level set to two e Debug is a project built with the debugger support included Optimisation is set to zero e Release is a project with optimised compile options producing code suitable for release in a product Optimisation is set to two These tutorials are designed to show you how to use the RSK and are not intended as a comprehensive introduction to the CS debugger compiler toolchains or the E1 emulator Please refer to the relevant user manuals for more in depth information
39. illator Frequency x1 2 16 MHz 4L m Figure 4 2 Clock setting tab R20UT3254EG0101 Rev 1 01 ENESAS Page 13 of 38 Mar 03 2015 RSKRX113 4 Code Generation Using the CS plug in 4 4 2 O Ports This peripheral will be configured to assign output pins for user LEDs and input pins for user switches with the exception of SW3 which is used as a trigger for the A D Converter peripheral Please refer to the RSK schematic for full details of the connectivity Double click on the I O Ports entry in the Code Generator gt Peripheral Functions list Configuration is required for Port2 Port3 and PortJ The port is selected from the tabs at the top of the Peripheral Functions window Configure the ports as shown in Figure 4 3 Port 2 Configuration Figure 4 4 Port 3 Configuration amp Figure 4 5 Port J Configuration Proceed to the next section to configure the Serial Communications Interface Portd Port Ez Port3 Porta Port5 Port3 Porta Pon Ponc PotD Pone PonF Port Pons P20 Unused 5 In D Out CMOS output P21 Unused In Out CMOS output P22 Unused In CMOS output Output 1 P23 Unused In CMOS output TI Output 1 P24 Unused Dln CMOS output Output 1 P25 5 Unused In CMOS output F Output 1 P26 Unused In D Out CMOS output P27 Unused Dln Out CMOS output Figure 4 3 Port 2 Configuration Pot Port Pon Pors Jona Ports Pong Porta Port Porc
40. k ok ok kk kk ok ok ok ok k k ok ok ok kk kk kk kkk kkk kkk kc ke kc ke kc ko kc ke kc ke kc ke kc ke ke ke kc ke ke e ke e e e okok ee kok porko kok ok Ck kk kk kk kk kk Ck KC kk oko oko ok kok kok kok AA Function Name lcd display adc Description Converts ADC result to a string and displays it on the LCD panel Argument uintl6 t adc result Return value none vk kok okok okok okok okok okok ke Sk okok okok okok okok ok okok okok okok Sk ke Sk ke Sk ke Sk ke Sk ke Sk ke Sk ke kk kk Sk ke RARA RA Sk ke Sk ke k ke ke ke k ok ke ke k ke e ke e e e e static void lcd display adc const uint16 t adc result Declare temporary character string char lcd_buf 4 Convert ADC result into a character string and store in the local string lcd buffer uintl6 to string lcd buf Ou adc result Display the ADC value Line 3 provides three characters so skip the unused leading zero RY R LCD DisplayPanelString PANEL LCD LINE3 uint8_t lcd buf 1 ROKK KKK RK KK A k k A ARK A ARR RR RRA RR RARA RAR ARA k k End of function lcd display adc RR KK KK KR RK KK KK ck ck ck ck ck ckckckckckckckckckckck ck ck ck ck ck ck ckckckckckckckckck ck ck ck ck ck ck ck ck k ck KK R20UT3254EG0101 Rev 1 01 RENESAS Page 30 of 38 Mar 03 2015 RSKRX113 6 User Code Integration ROKK KK KK okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok ok
41. nshots The Tutorial project is a standard RSK sample and can be obtained by following the steps shown in the Quick Start Guide 6 2 LCD file copying API functions for the RSK LCD App v2 display are included in the following files r lcd appv2 c r lcd appv2 h Using WindowsTM Explorer locate the Tutorial project folder and copy the files above to the project folder created in section 3 2 this will be CAWorkspace WCG Tutorial if following the example screenshots The Tutorial project is a standard RSK sample and can be obtained by following the steps shown in the Quick Start Guide R20UT3254EG0101 Rev 1 01 RENESAS Page 23 of 38 Mar 03 2015 RSKRX113 6 User Code Integration 6 3 Including files in the CS Project e Right click on C Source Files in the Project Tree ES Proper gg Parphera Functions and select Add gt Add File 203 8 C Source Files Property a CG Tutorial Project e Browse to and select the following files copied in jf RSFSTIEASFP Microcontroller 4 Category Information Category name Fa i Code Generator Design Tool Shortcut to a folder the section above and click Add A c Gui Tad RUE r rsk utility c Ss RX Simulator Debug Tool 7 File r lcd appv2 c LAU Build tool generated files i m jui A Code Generator e Right click on Dependencies in the Project Tree g and select Add gt Add File noe BI Op
42. ode Insertion Insert the following between the user code delimiter comments at the end of the file Start user code for function Do not edit comment generated here Exported functions used to transmit a number of bytes and wait for completion MD STATUS R SCI1 AsyncTransmit uint8_t const tx buf const uint16 t tx num Character is used to receive key presses from PC terminal extern uint8 t g rx char Flag used to control transmission to PC terminal extern volatile uint8 t g tx flag End user code Do not edit comment generated here R20UT3254EG0101 Rev 1 01 EN ESAS Page 27 of 38 Mar 03 2015 RSKRX113 6 User Code Integration 6 4 7 r cg main c Code Insertion Insert the following between the user code delimiter comments as shown below in the file section designated Includes Start user code for include Do not edit comment generated here include r cg s12ad h include r lcd appv2 h include r rsk utility h include rskrx113def h End user code Do not edit comment generated here Insert the following between the user code delimiter comments as shown below in the file section designated Global Variables and functions Start user code for global Do not edit comment generated here Welcome banner displayed on serial port at startup static uint8 t welcome banner RSK RX113 Tutorial Press c or SW3 for ADC Conversion r n e Prototype
43. ok okok okok okok okok okok okok ok okok okok ke ke ke ke kok x Function Name uart display adc Description Converts ADC result to a string and sends it to the UARTI Argument uint8 t adc count uintl6 t ADC result Return value none vk kok CK k k kk Sk okok okok okok okok okok okok ok Sk ke Sk ke Sk ke kk kk Sk ke kk kk kk kk kk kk kk kk kk kc ke kk kk kc ke kk kok k ke ke ke ke e ke e e e e static void uart display adc const uint8 t adc count const uintl6 t adc result Declare a temporary variable char a Declare temporary character string static uint8 t uart buffer ADC xH Value xxxH r n Convert ADC result into a character string and store in the local Casting to ensure use of correct data type a char adc count amp 0x000F uart buffer 4 char a lt 0x0A a 0x30 a char adc result amp OxOF00 8 uart buffer 14 char a lt 0x0A a 0x30 a char adc result amp 0x00F0 gt gt 4 uart buffer 15 char a lt 0x0A a 0x30 a char adc result 0x000F uart buffer 16 char a lt 0x0A a 0x37 a 0x37 a 0x37 a 0x30 a 0x37 Send the string to the UART R SCI1 AsyncTransmit uart buffer sizeof uart buffer ROKK KR RK KK RO RK KK A ARK RR ROO ROO RR kk Ck RR RR koc k kk Ck A koc ko kk A ko kk koe kk kk kkk End of function uart display adc PK Ck kk kk ok ok k ok ok ok
44. oke okok ok okok ok ok ok ok ok ok okok ok ok okok okok ok okok ok okok okok RK KKK KK RK KK End user code Do not edit comment generated here 6 4 3 r cg s12ad h Code Insertion Open this file by double clicking on the file name in the CS Project Tree window Insert the following at the end of the file between the user code delimiter comments as shown below Start user code for function Do not edit comment generated here Flag indicates when A D conversion is complete extern volatile uint8 t g adc complete Functions for starting and stopping software triggered A D conversion void R S12AD SWTriggerStart void void R S12AD SWTriggerStop void End user code Do not edit comment generated here R20UT3254EG0101 Rev 1 01 RENESAS Page 25 of 38 Mar 03 2015 RSKRX113 6 User Code Integration 6 4 4 r cg s12ad user c Code Insertion Open this file by double clicking on the file name in the CS Project Tree window Insert the following between the user code delimiter comments as shown below in the file section designated Global variables and functions ad or globa omment generated here Flag indicates when A D conversion is complete volatile uint8 t g adc complete End user code Do not edit comment generated here Insert the following in to the function static void r s12ad interrupt void Start user code Do not edit comment generated here Flag that the AD
45. play the results on a terminal program via the Virtual COM port and also on the LCD display attached to the RSK Following a tour of the key user interface features of Code Generator in 84 3 the reader is guided through each of the peripheral function configuration dialogs in 4 4 In S6 the reader is familiarised with the structure of the template code as well as how to add custom code in the areas provided by the Code Generator 4 2 Enabling Code Generator After installation of CS Code Generator must be enabled This step is only required once CS will remember this setting on subsequent launches From the Tool pull down menu select Plug in Setting On the Additional Function tab click the box next to the Code Generator Pin View Plug in option and ensure it is ticked Basic Function Additional Function Module Name 7 8 Code Generator Plugin BEZE Code Generator PinView Plugin Description Plugin to generate the device driver automatically for V850 78K0 78KOR RL78 G12 G13 G1 Plugin to generate the device driver automatically and to view the device configuration for RX Click OK CS needs to restart to enable this selection select Yes from the Question dialogue box After restarting Code Generator Design Tool node will now be shown in the left hand Project Tree window pane E Pev 7 2 2 2 E Code Generator Property F CG Tutorial Project 4 GenerateFileMo
46. resulting value on the terminal window and the LCD R20UT3254EG0101 Rev 1 01 RENESAS Page 33 of 38 Mar 03 2015 RSKRX113 8 Additional Information 8 Additional Information Technical Support For details on how to use CS refer to the manual available on the DVD or from the web site Online technical support and information is available at http www renesas com rskrx113 For information about the RX113 Group microcontrollers refer to the RX113 Group Hardware Manual For information about the RX assembly language refer to the RX Family Software Manual Technical Contact Details Please refer to the contact details listed in section 8 of the Quick Start Guide General information on Renesas microcontrollers can be found on the Renesas website at http www renesas com Trademarks All brand or product names used in this manual are trademarks or registered trademarks of their respective companies or organisations Copyright This document may be wholly or partially subject to change without notice All rights reserved Duplication of this document either in whole or part is prohibited without the written permission of Renesas Electronics Europe Limited 2014 Renesas Electronics Europe Limited All rights reserved 2014 Renesas Electronics Corporation All rights reserved 2014 Renesas System Design Co Ltd All rights reserved R20UT3254EG01001 Rev 1 001 EN ESAS Page 34 of 38 Dec 15 2014 REVISION HISTORY
47. rity Level 15 highest Callback function setting 4 Transmission end 4 Reception end 4 Reception error Figure 4 7 SCI1 Setting tab 4 4 4 12 bit A D Converter This peripheral is configured to sample the analogue output value of the RV1 potentiometer The A D Converter is set to perform a sample when the user presses SW3 which is connected to the ADTRGO pin of the microcontroller Double click on the 12 bit A D Converter entry in the Code Generator gt Peripheral Functions list Configure the General setting and Setting sub tabs as shown in Figure 4 8 A D Converter General setting tab amp Figure 4 9 A D Converter Setting tab Code Generator configuration is now complete Proceed to the next section to generate the code Unused 9 Analog input channel mode Note When the 12 bit A D converter is used output from port 4 and port 9 should not be used D Temperature sensor mode D Internal reference voltage mode Figure 4 8 A D Converter General setting tab R20UT3254EG0101 Rev 1 01 RENESAS Page 16 of 38 Mar 03 2015 RSKRX113 4 Code Generation Using the CS plug in General setting Operation mode setting Single scan mode Conversion mode setting 9 Normal AVCC gt 1 84 VREF Setting Group scan mode High speed AVCC gt 2 4V Continuous scan mode AVCCO VREF Setting AVSSO Double trigger mode setting Intemal r
48. subsystems and peripherals the user can click the Generate Code button resulting in a fully configured CS project Navigation to the MCU peripheral configuration screens may be performed by double clicking the required function in the Code Generator Peripheral Function on the left It is also possible to see a preview of the code that will be generated for the current peripheral function settings by double clicking the required function in the Code Generator Code Preview on the left R20UT3254EG0101 Rev 1 01 RTENESAS Page 11 of 38 Mar 03 2015 RSKRX113 4 Code Generation Using the CS plug in 4 4 Code Generation In the following sections the reader is guided through the steps to configure the MCU for a simple tutorial project containing ADC with external switch trigger Serial Communications Interface SCl and LCD Output 4 4 1 Clock Generator Figure 4 2 shows a screenshot of Code Generator with the Clock Generator function open In this tutorial we are using the 16 MHz crystal resonator for the main clock source with the PLL circuit used as a multiplier The sub clock oscillator is used as a clock source for the LCD peripheral Double click on the Clock Generator entry in the Code Generator Peripheral Functions list Configure the Clock Generator options as shown in Figure 4 2 Proceed to the next section to configure the I O Ports R20UT3254EG0101 Rev 1 01 EN ESAS Page 12 of 38 Mar 03 2015 RSKRX113
49. torial Project EJ R5F51138AxFP Microcontroller Code Generator Design Tool VCC setting A Pin View 27 V lt VCC lt 3 6 V 24 VCC 27 V 18 V lt VCC lt 24 V cQ E Ej Main clock oscillator and SSI clock SSISCK setting V Operation Clock Generator He Voltage Detection Circuit Clock Frequency Accuracy k Low Power Consumption Interrupt Controller Unit Buses Main clock oscillation source Resonator Frequency 16 MHz Oscillator wait time 2 cycles O5 us Data not Ponal Oscillation stop detection function Disabled v Event Link Controller VO Ports Multi Function Timer Pulse Port Output Enable 2 8 Bit Timer Compare Match Timer Realtime Clock Independent Watchdog Tim Serial Communications Inter I2C Bus Interface Serial Peripheral Interface CRC Calculator 12 Bit A D Converter 12 Bit D A Converter Comparator B Data Operation Circuit ode Preview _ hd m H PLL circuit setting amp E Operation E Sub clock oscillator and ATC RTCSCLK setting E Operation E Middle drive capacity H CCCCCCCCCCCCCCCCCCCCC All Messages E Output Error List les FE F1 FH les FA En FE zi DISCONNECT o Figure 4 1 Initial View Code Generator provides GUI features for configuration of MCU subsystems and peripherals Once the user has configured all required MCU
50. us All trademarks and registered trademarks are the property of their respective owners Table of Contents TEOVEIVIEW 255 o dd mo de ad ed k SRBA od A na o kud 7 1 1 PUIPOS CE 7 12 E Eel III MIHI fO MU MEI 7 A O 8 Ss Project Creation WI Oda ido 9 3 1 Introduction ttem eem eee t e teet eed 9 3 2 Greating the Project sans ed nee eet ou du ditte aia e ra A vanu on 9 4 Code Generation Using the CS plug IN eee eee eee eee eee eee eee een nn 10 4 1 INTOdUCUION e EE ER 10 4 2 Enabling Code Generator ssssssssssssssesseeeee seen entren nnne nns LKAA EKK AKA nnns III IIIIIIIKIIAAI 10 4 3 Code Generator TOUF eseesesro se esse snneenestesoesunentasrnsrasss unsezasrastassigsemsresrefvastestenszanneetrevsesrenranrnesinio ti 4 4 Gode GENERATION sa i iei otc ete ine eee To aK EN nets oe Lo Tana ces eT aane To Peeves EZA ULAN II TRA Ia SEA Ko Pra UR E 12 4 4 1 Glock Generator creto eb eet tib bem a e oa ol 12 4 4 2 exea Ma ET C mm ptm RI ELO 14 4 4 3 Serial Communications Interface ssseseecessusssssssssssssusasnnsssssensasanssssssssssnsannnssos 15 4 4 4 T2 bit A D COnVerter 5o Ii eter f poe certe Pe Ratios eser te Pag loves da haha potesse A 16 4 4 5 Generating the codes oar La EN GS ee Hd erg coa Dee e Hee itive 18 De diese mes ile tata MEE 19 Sali Adding Project Folders unii nme im du etnia 22 6 User Code Integra c aran a 23 6 4 Support file copying Ane erit e
51. use in products or systems that may pose a direct threat to human life or bodily injury artificial life support devices or systems surgical implantations etc or may cause serious property damages nuclear reactor control systems military equipment etc You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application for which it is not intended Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics 6 You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges 7 Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions Further Renesas Electronics products are not subject to
Download Pdf Manuals
Related Search
Related Contents
DRAFT prEN 14225-2 Sappy Land Marzo 2011 - Eshop Copyright © All rights reserved.
Failed to retrieve file