Home

Renesas Starter Kit+ for RX71M Code Generator Tutorial Manual

image

Contents

1. End user code Do not edit comment generated here Insert the following code in the transmitend call back function for SCI6 static void r sci6 callback transmitend void Start user code Do not edit comment generated here End user code Do not edit comment generated here Now insert the following function in the user code area at the end of the file BKK KR KK KKK KK KK kk ok kk k k k k k kk k k k kk k k k ck ck ck ck ck ck ck ckckckckckckckckck k k k kk ck ck ck KK KK k k k k KK ck ck k k kk Function Name R SCI6 SPIMasterTransmit Description This function sends SPI6 data to slave device Arguments tx buf transfer buffer pointer tx num buffer size Return Value status MD OK or MD ARGERROR CK CK Ck kk ok kk Ck ok kk okok k k ko kk Ck ok kk Ck kk Ck ke kok kk kk ke kk ke kk kok kk k ke kk okokokok ok kk k kk k k kk k k kk k kk kk kk kk MD STATUS R SCI6 SPIMasterTransmit uint8 t const tx buf const uint16 t tx num MD_STATUS status MD_OK clear the flag before initiating a new transmission sci6 txdone FALSE Send the data using the API status R_SCI6_SPI_Master_Send tx_buf tx num Wait for the transmit end flag while FALSE sci6 txdone Wait return status BKK KK kk kk okok k k k k k k k okok ok ok ok kk Ck okok ok okok okok ok kkk ok okok kk Ck kk kk okok Sk ke ko okok okok ck ck ck ck ck ck okok ck kkk kk kkk kk kk k End
2. End user code Do not edit comment generated here R20UT3220EG0100 Rev 1 00 RTENESAS Page 36 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project Next add the highlighted code below in the user code area inside the main function and the code inside the while loop resulting in the code shown below void main void R MAIN UserInit Start user code Do not edit comment generated here x Initialize the switch module R SWITCH Init x Initialize the debug LCD R LCD Init Displays the application name on the debug LCD R LCD Display 0 uint8 t RSK RX71M R LCD Display 1 uint8 t Tutorial R LCD Display 2 uint8 t Press Any Switch while 1U m J End user code Do not edit comment generated here Then add the definition for the switch call back get adc and lcd display adc functions in the user code area for adding at the end of the file as shown below BRK KR KR RK KK KK KK kc kckck ck ck kk ck kckckckckckckckckck ck ck ck ck ck ck ck ckckckckckckckck ck ck ck ck k ck ck ck KKK KK KK KK kck ck ck ck ck kk Function Name cb switch press Description Switch press callback function Sets g adc trigger flag Argument none Return value none vk kok okok okok okok okok okok okok okok okok ok Sk ke kk Sk ke kk kk Sk ke kk kk kk Sk ke Sk ke kk kc ke kk kk kk kc ck kk kk kc ko kc ko kc ko kk ke ke ke ke e ke e e e e Stati
3. ICU IRQCR irq no BYTE uint8 t 04 ICU IRO EDGE FALLING BRR KK KK KK A ok ok IKK KAA A RR RR Ck ck ck ck ck ck ck k ck RR RR RR RR RR RARA CK CK Ck Ck ck ck k ck kkk k End of function R ICU IRQSetFallingEdge OKCKCKCkCk Ck k ck kk Kok kk KCkOkCkCkCkCkCk ck ck ck ck ck ck ck ck ck kCkCkCKCKCkCkCk Ck ck ck ck k ck ck ck ck KCKCKCKCKCkCk Ck ck ck ck ck ck ck ok ok ck kck ck ck ck ck kkk kk ek ARK K k k k kk ke kk ko ke kk ke ko kk ke RARA ke ke kk ke kk Ck ke kk ke ke kk ke kk Ck k kk ke kk I kk k k kk k ke k k ke k k I k k kc k k k kk k k R ICU IRQSetRisingEdge This function sets clear the rising edge trigger for the specified ICU IRO Hints t Iira no uint8_t set_r_edge clearing Return Value None kok okok kok kok kok kok k kok kok kok kok k kk kok kok kk k kok k k kok kok kk k kk kok kk k k kk k kk k k kk k k kk k kk k kk kk ke ke ke void R ICU IROSe Function Name Description Arguments Q TE 1 if setting rising edge triggered tRisingEdge const uint8 t irq no const uint8 t set r edge LF 1 set_r_edge ICU IRQCR irq no BYTE 08 ICU IRQ EDGE RISING else ICU IRQCR irq no BYTE uint8 t _08_ICU_IRQ_EDGE_RISING BR K K k k IKK I IKK IK ke IKK I kk ke IK ke k kk ke I I ke kk ke k k ke k k k k k k k k k kok k k k kok I I k k kk k k k k End of function R ICU IROSetRisingEdge vok ok okok kok kok ok ok okok okok ok kok
4. 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 Electronics Hong Kong Limited Unit 1601 1611 16 F Tower 2 Grand Century Place 193 Prince Edward Road West Mongkok Kowloon Hong Kong Tel 852 2265 6688 Fax 852 2886 9022 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 06 02 Hyflux Innovation Centre Singapore 339949 Tel 65 6213 0200 Fax 65 6213 0300 Renesas Electronics Malaysia Sdn Bhd Unit 1207 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 India Pvt Ltd No 777C 100 Feet Road HALII Stage Indiranagar Bangalore India Tel 91 80 67208700 Fax 91 80 67208777 Renesas Electronics Korea Co Ltd 12F 234 Teheran ro Gangnam Gu Seoul 135 080 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 2015 Renesas Electronics Corporation All rights reserved Colophon 4 0 RX71M Group
5. 7 1 Running the Tutorial Click the Go button or press F5 to begin the program from the current program counter position It is recommended that you run through the program once first and then continue to the Tutorial manual to review the code Once the program has been downloaded onto the RSK device the program can be executed gt R20UT3220EG0100 Rev 1 00 RENESAS Page 48 of 53 Jan 23 2015 RSK RX71M 8 Additional Information 8 Additional Information Technical Support For details on how to use CS refer to the help file by opening CS then selecting Help 20l Window Hel Help Contents from the menu bar B do A o Help _ Open Help for Start Panel F1 Sh One Point Advice art JN Tutorial Leam Browse Renesas Electronics Microcontrollers Web A Detail Version Information EN About For information about the RX71M group microcontroller refer to the RX71M 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
6. reguirements of the Electromagnetic Compatibility Directive and could lead to prosecution The product generates uses and can radiate radio freguency 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 e
7. 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 O 2015 Renesas Electronics Europe Limited All rights reserved O 2015 Renesas Electronics Corporation All rights reserved O 2015 Renesas System Design Co Ltd All rights reserved R20UT3220EG0100 Rev 1 00 RENESAS Page 49 of 53 Jan 23 2015 REVISION HISTORY RSK RX71M Code Generator Tutorial Manual Rev Date Description Page Summary 1 00 Jan 23 2015 First Edition issued Renesas Starter Kit Manual Code Generator Tutorial Manual Publication Date Rev 1 00 Jan 23 2015 Published by Renesas Electronics Corporation RENESAS SALES OFFICES Renesas Electronics Corporation Refer to http www renesas com for the latest and detailed information http www renesas com 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 9251 Yonge Street Suite 8309 Richmond Hill Ontario Canada L4C 9T3 Tel 1 905 237 2004 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
8. 1 00 RTENESAS Page 43 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project SW3 is directly wired into the ADTRGOn pin so will cause the interrupt to fire else if TRUE g_adc_complete Get the result of the A D conversion R_S12AD0_Get_ValueResult ADCHANNELO amp adc result Display the result on the LCD lcd display adc adc result Reset the flag g adc complete FALSE End user code Do not edit comment generated here Then add the following function definition in the user code area at the end of the file BR K K k k okok ok ok okok ok okok dk ok okok ok ok oke ok ok okok k ok okok ok ok oke k k okok k ok k k ok ok kk ok k k k k k k ok k k dk ok okok ok ok okok ok okok k ok okok ok ok k k k k k Function Name uart display adc Description Converts adc result to a string and sends it to the UARTI Argument z uint8 t ade count uintl6 t adc result Return value none o kok Ck kk oke ok Sk ok Sk ok Sk ke ok ok Sk ok ok ke ok ok ok ok ok ok ok ok ok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok ke ke ke ke ke ke ke ke ke ke e e x 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 char uart buffer ADC xH Value xxxH r n Convert ADC result into a character string and store in the l
9. 23 2015 RSK RX71M 4 Code Generation Using the CS plug in 4 4 2 Interrupt Controller Unit Referring to the RSK schematic SW1 is connected to IRQ5 P15 and SW2 is connected to IRQ2 P12 SW3 is connected to directly to the ADTRGOn and will be configured later in 4 4 4 Navigate to the Interrupt Controller Unit node in Code Generator and in the General tab configure these two interrupts as falling edge triggered as shown in Figure 4 3 below 73 Property Zi Peripheral Functions S Generate Code S D demono a 57 SDA GBGADDOJISAJJ BJ E i Group Interrupts Interrupt B A selection Fast interrupt setting C Fast intemupt emupt source BSC BUSERR vect 16 E Software interrupt setting Software interupt jo Level 15 highest Software interupt 2 Priori Level 15 highest NMI setting mu E NMI pin intemupt jedge Falling v Digital fite No filter y 0 IRQO setting IRQO P30 D No filter 0 Low level v Priori Level 15 highest IRQI setting 7 IRGI Pin P31 Digital filter No filter 0 dge Low level Priori Level 15 highest IRQ2 setting v IRG2 Pin P12 Digtalfiter No filter lo Valid edge Falling Priority Level 15 highest v IRQ3 setting E IRQ3 n P33 gt gital filter No filter 0 Low level v Priori Level 15 highest IRQ4 setting C IRG4 Pin PBI Digital filte N
10. CC RX Build Tool a Production Sl RX Simulator Debug Tool s File R20UT3220EG0100 Rev 1 00 RENESAS Page 10 of 53 Jan 23 2015 RSK RX71M 4 Code Generation Using the CS plug in 4 Code Generation Using the CS plug in 4 1 Introduction Code Generator is a Windows GUI tool for generating template C source code and project settings for the RX71M When using Code Generator the user is able to configure various MCU features and operating parameters using intuitive GUI controls thereby bypassing the need in most cases to refer 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 Auick 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 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 then free to add custom code to meet their specific reguirement Custom code should be added whenever possible in between the following comme
11. FALSE R S12AD0 Get ValueResult ADCHANNELO amp adc result Set AD conversion start trigger source back to ADTRG0n pin R S12AD0 Start return adc result SEEK ok k k kok k k ko oko k k k k k k k k kok k kok kok kok k k k k k k k kok k k k k ko kok kok kok k k k k ke kk kok kk k kok kok kok kok k k k k k k End of function get adc kok kok k k kok o ok ke kk ko kk k ke kk ko ke kk ok ke kk ok oke oka ok ok oke aka ok oke kk ok oke oka ok ke oke aka ok okra ok ke oke oka ok ok oke ak ok kk ok ok oke dk ok okok dk ok okok ok ok ok ok I S EEK K k k k k k I IKK kk o k k k I k kok kk k k I k k k ke kk ke kk k k k ke ke kk k k k ke ke kk ke k kk k k kk ke kk I I kk k kk k Function Name lcd display adc Description Converts adc result to a string and displays it on the LCD panel Argument uintl6 t ade result Return value 5 none CK CK kk ko kk Ck ok kk Ck kk Ck ko kk Ck Ck kk Ck ko kk ok kk Ck ke kk Ck kk I kk Ck ke kk ke kk Ck ok kk Ck ke RARA RAR RAR ek ok ok okok okok static void lcd display adc const uintl6 t adc result Declare a temporary variable uint8_t a Declare temporary character string char lcd buffer 11 ADC XXXH Convert ADC result into a character string and store in the local Casting to ensure use of correct data type a uint8 t adc_result amp 0x0F00 gt gt 8 led buffer 6 char a lt Ox0A a 0x30 a 0x37 a uint8
12. 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
13. Tutorial and click Add Repeat the above steps to add the files ascii h r okaya lcd h to the Dependencies folder Code must be inserted in to the user comments as follows Start user code for xxxxx End user code Do not edit comment 5 3 File y Build tool generated files Code Generator Mi C Source Files Dependenc Add 3 Open Folder with Explorer EN Windo s Explorer Menu x4 Remove from Project m j ix Copy y Paste v A Add File X3 Add New File MR Add New Category Shift Del Ctrl C Ctrl V code area in many files in this project in the areas delimited by Do not edit comment generated here 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 needs to subsequently change any of the Code Generator generated code In the CS Project Tree expand the Code Generator folder and open the file r cg userdefine h by double clicking on it Insert the following defines in between the user code delimiter comments as shown below R20UT3220EG0100 Rev 1 00 Jan 23 2015 RENESAS Page 29 of 53 RSK RX71M 5 Completing the Tuto
14. kok ok ok k k ke kk kok kok okok okok okokok kok kk k kk kok kk k k kk k kk k k kk k k okok k kk k kc ke koe ke ke ke kk R20UT3220EG0100 Rev 1 00 Jan 23 2015 RENESAS Page 34 of 53 RSK RX71M 5 Completing the Tutorial Project Open the r_cg_icu_user c file and insert the following code in the user code area for include near the top of the file O In the same file insert the following code in the user code area inside the function r_icu_irq2_interrupt In the same file insert the following code in the user code area inside the function r icu irq5 interrupt 5 4 2 De bounce Timer Code Open the r cg cmt user c file and insert the following code in the user code area for include near the top of the file In the same file insert the following code in the user code area inside the function r cmt cmi1 interrupt In the same file insert the following code in the user code area inside the function r cmt cmi2 interrupt 5 4 3 Main Switch and ADC Code In this part of the tutorial we add the code to act on the switch presses to activate A D conversions and display the result on the LCD In 4 4 4 we configured the ADC to be triggered from the ADTRGO pin In this code we also perform software triggered A D conversion from the user switches SW1 and SW2 by reconfiguring the ADC trigger source on the fly once an SW1 or SW2 press is detected In the CS Project Tree expand the Code Generator folde
15. not subject to 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 produci 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 producis 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 app
16. of function R SCI6 SPIMasterTransmit vk okok okok okok okok okok Ck ko ko okok ok RK KK KK KKK KK KK KKK KKK KKK KK KK KK RK KKK KKK KK KK kk Ck Ck kk ko ke ke ke ke ke ke ke KK This function uses the transmit end callback function to perform flow control on the SPI transmission to the LCD and is used as the main API call in the LCD code module R20UT3220EG0100 Rev 1 00 RTENESAS Page 31 of 53 Jan 23 2015 RSK RX71M 5 Gompleting the Tutorial Project 5 3 2 CMT Code The LCD code needs to insert delays to meet the timing reguirements of the display module This is achieved using the dedicated timer which was configured using Code Generator in 4 4 3 Open the file r cg cmt h and insert the following code in the user area for function at the end of the file Start user code for function Do not edit comment generated here End user code Do not edit comment generated here Open the file r cg cmt user c and insert the following code in the user area for global at the beginning of the file Start user code for global Do not edit comment generated here End user code Do not edit comment generated here Scroll down to the r cmt cmiO interrupt function and insert the following line in the user code area static void r cmt cmi0 interrupt void Start user code Do not edit comment generated here End user code Do not edit comment generated here Then insert the following function in
17. the user code area at the end of the file III e e e oo oa o o oa o o a oa o oa o o ao oco o IG ICICI ICICI ICI ICR ICI II a ae a x Function Name R CMT MsDelay Description Uses CMTO to wait for a specified number of milliseconds Arguments uint16 t millisecs number of milliseconds to wait Return Value None kok kok kk ko kk ko ok oke o ok ok oke k oko k ok oke o ok ok oke k oko I I kok kk ke k k ko ak kok oko k kok k oko kok ok ke k k ke ke RAR RARA ARRAY void R CMT MsDelay const uintl6 t millisec uint16 t ms count 0 do R CMTO Start while FALSE one ms delay complete Wait R_CMTO_Stop one_ms_delay_complete FALSE ms_count while ms_count lt millisec BRR k k k k k k RK KKK KK KK KK KK KR AA End of function R_CMT_MsDelay A KKK AK KK A ARK ARK KI ARR RR RR RR RRA RR IRR IA AK I A Select Build Project from the Build menu or press F7 CS will build the project with no errors The project may now be run using the debugger as described in 6 The program will display RSK RX71M Tutorial Press Any Switch on 3 lines in the LCD display R20UT3220EG0100 Rev 1 00 RENESAS Page 32 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project 5 4 Switch Code Integration API functions for user switch control are provided with the RSK Refer to the Tutorial project folder created according to the Quick Start Guide procedure Locate the files
18. 1 V High drive output P27 C Unused In Out _ Pull up CMOS output v 7 Output 1 High drive output cpi m n Figure 4 14 I O ports Port2 P45 is used as one of the LCD control lines together with P46 and P47 Configure these lines as shown in Figure 4 15 R20UT3220EG0100 Rev 1 00 EN ESAS Page 22 of 53 Jan 23 2015 RSK RX71M 4 Code Generation Using the CS plug in Zi Peripheral Functions d ta 0 C A d amp Mr LR V mm nmm P40 9 Unused i Om Puhp CMOS output I Output 1 PH Umed Oh Out Pulup CMOS output M C Output 1 E P42 Unused In Out C Pultup CMOS output v Output 1 P43 Unused Oh O Out Pulup CMOSoutput M Output 1 P44 Unused O In Out I Pull up CMOS output lt C Output 1 P45 Unsed Oh Out Pulup CMOS output M v Output 1 P46 Unused h Out C Pullup CMOS output Y Output 1 P47 Old Oh Out C Pulup CMOS output Output 1 M 4 m r Figure 4 15 I O ports Port4 Peripheral function configuration is now complete Save the project using the File gt Save Project menu item then click Generate Code The Output pane should report The operation of generating file was successful as shown Figure 4 16 below R20UT3220EG0100 Rev 1 00 EN ESAS Page 23 of 53 Jan 23 2015 RSK RX71M 4 Co
19. 1MLCxBG 176pin Product Name R5F571MLCxFC in E R5F571MLCxFB 144pi On chip ROM size KBytes 4096 Select R5F571MLCxFC 176pin 3 SEMIS Re Ono RAM size oo e Ensure that in the Kind of project pull ib R5F571MLCxFF 100pin down Empty Application CC RX is 8B R5F571MLCxLC 177pin Bi R5F571MLCxLJ 100pin selected dE R5F571MLCxLK 145pin e Choose an appropriate name and M eoe come location for the project then click E Create Kind of project Empty Application CC RX v Note this tutorial assumes the project Fiet nee LE pala is named and located at the place Place C workspace Browse shown opposite Ea V Make the project folder e If the folder entered cannot be found a Question dialogue with be displayed evo click Yes 7 Pass the file composition of an existing project to the new project Project to be passed Browse Copy composition files in the diverted project folder to a new project folder Create Cancel Help Jan 23 2015 RSK RX71M 3 Board Layout e CS will create the blank project with the standard project tree A Code Generator node may also be shown if previously enabled Bg um CG Tutorial Project BE R5F571MLCxFC Microcontroller API output control umu okt Pin View File generation control y Ex Peripheral Functions Register files E e Code Preview Reporttype LA
20. 2 NE S AS Renesas Electronics Corporation R20UT3220EG0100
21. 20UT3217EG RSK hardware Tutorial Provides a guide to setting up RSK RSK RX71M Tutorial Manual R20UT3218EG environment running sample code and debugging programs Quick Start Provides simple instructions to setup the RSK RX71M Quick Start R20UT3219EG Guide RSK and run the first sample Guide Code Generator Provides a guide to code generation RSK RX71M Code Generator R20UT3220EG Tutorial Manual and importing into the CS IDE Tutorial Manual Schematics Full detail circuit schematics of the RSK RX71M Schematics R20UT3216EG RSK Hardware Provides technical details of the RX71M RX71M Group Hardware R01UH0493EJ Manual microcontroller Manual 2 List of Abbreviations and Acronyms Abbreviation Full Form ADC Analog to Digital Converter API Application Programming Interface bps Bits per second CMT Compare Match Timer COM COMmunications port referring to PC serial port CPU Central Processing Unit DVD Digital Versatile Disc El Renesas On chip Debugging Emulator GUI Graphical User Interface IDE Integrated Development Environment IRQ Interrupt Request LCD Liquid Crystal Display LED Light Emitting Diode LSB Least Significant Bit LVD Low Voltage Detect MCU Micro controller Unit MSB Most Significant Bit PC Personal Computer Pmod This is a Digilent Pmod Compatible connector Pmod is registered to Digilent Inc Digilent Pmod In
22. C 7 A 0 D o LENESAS RX71M Group Renesas Starter Kit Code Generator Tutorial Manual For CS RENESAS MCU RX Family RX700 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 00 Jan 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
23. Disabled PLL circuit setting Operation PLL clock source Main clock oscillator Input frequency division ratio x1 Frequency multiplication factor x 10 0 Frequency 240 MHz Sub clock oscillator and RTC RTCSCLK setting Operation Sub clock oscillator drive capacity Drive capacity for low CL Frequency 32 768 kHz Oscillator wait time 2252 73 ms Aciual value 2296 182 ms High speed clock oscillator HOCO setting mi 0 ti Freguency 16 v MHz Low speed clock oscillator LOCO setting wo Frequency 240 kHz IWDT dedicated low speed clock oscillator IWDTLOCO setting F Opera Frequency 120 kHz RTC clock setting E Operation Clock source Sub clock oscillator System clock setting Clock source PLL circuit System clock ICLK x1 240 MHz Peripheral module clock PCLKA x12 Y 120 MHz Peripheral module clock PCLKB x 14 60 MHz Peripheral module clock for ADC PCLKC x 1 4 60 MHz Peripheral module clock for ADC PCLKD x14 8 MHz Extemal bus clock BCLK x14 860 MHz Flash IF clock FCLK x14 60 MHz USB clock UCLK x 15 4 MHz BCLK pin output setting 7 Operation C Enable BCLK forced output Clock output source BCLK SDCLK pin output setting Operation Figure 4 2 Clock setting tab Proceed to the next section on Interrupt R20UT3220EG0100 Rev 1 00 1234 NE S AS Page 14 of 53 Jan
24. alling edge triggered 0 if not OKCKCKCkCkCk k kok AAA IRR RA ck ck k KCKCKCKCKCkCk Ck ck kkk kkk ck K KCKCkCKCKCk Ck ck ck ck ck k ck ck ck ck ck ck k ck ck ck ck k kkk uint8 t R ICU IRQ sFallingEdge const uint8 t irg no uint8 t falling edge trig 0x0 if ICU IROCR irq no BYTE amp 04 ICU IRO EDGE FALLING falling edge trig 1 return falling_edge_trig BOR K K k k IKK KKK k KK IK k IKK ke I I ke k k k kok k k k k k k k k oko kk k k k k k k kk k k k kok k k k kk I k kk IK End of function R ICU IROIsFallingEdge okok okok kok kok ok kok okok ok kok kok okok ok k k kok kok kk k kk kk kk kok kk k kk k k kk k k kk k kk k k kk k kk k k kk k kk ke ke ke ke SEEK kkk kk k kk k k kk k kk k k k k k k k k k k kok k k k k k kok kok kok k k k k k kok kok kok k kok kok kok kok kk k kok kok kok k kk k k k k I R_ICU_IRQSetFallingEdge This function sets clears the falling edge trigger for the specified ICU_IRQ uint8 t irg no uint8 t set f edge clearing Return Value None okok ok okok kok okok ok okok k okok ok kok kok okok k kk kok kok kok ko kok kok kok kok kok k kok kok kok kok kk k kk k k kk k k kk k kk k k koe ke ke ke eek void R ICU IROSe x Function Name Description Arguments 1 if setting falling edge triggered 0 if tFallingEdge const uint8 t irg no const uint8 t set f edge iE 1 set_f_edge ICU IRQCR irq_no 04_ICU_IRQ_EDGE_FALLING else
25. 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 R20UT3220EG0100 Rev 1 00 AS Page 8 of 53 Jan 23 2015 RENES RSK RX71M 3 Project Creation with CS 3 Project Creation with CS 3 1 Introduction In this section the user will be guided through the steps reguired to create a new C project for the RX71M MCU ready to generate peripheral driver code using Code Generator This project generation step is necessary to create the MCU specific project and debug files 3 2 Creating the Project To use the program start CS Windows RH850 7 8 Vista Start Menu Start Menu gt All Programs gt Renesas Electronics CS gt CS for CC RX Windows 8 From Apps View click CS for CC RX RH850 icon e CS will show the Start Page Use the Create New Project i A 7 be led GO button to Create a New Project GO eii pn z NIA by reusing the file configuration registered to an existing project Create New Mrilti core Drniect e In the Create Project dialog select Create Project ea RX from the Microcontroller pull icrocontroller v dawn Mi troll RX v e n the Using Microcontroller list control scroll down to RX71M and A Search microcontroller Update expand the tree control by clicking dif R5F57
26. ation level Yes debug th e output fil e Dutputs additional information for inter module optimization Optimization type 1 1 Dutputs a source list file Nof nolistfile i To mere debug information from 4 Frequently Used Options for Assemble the Release build mode in the Additional include paths Additional include paths 0 CC RX Property window select System include paths System include paths 0 Macro definition Macro definition 0 the Common Options tab at the Frequently Used Options for Link bottom of the window pane For Using libraries Using libraries 0 A A A Dutputs debugging information Yes Outputs to the output filej DE Bug the Outputs debugging information a SE option select No nodebug UE cr Selects whether to output debugging information Reset the build mode back to This corresponds to the debug and nodebug options of the compiler Debug using the Build Mode pull down control e From the menus select File gt Save Al to save all project L3 settings 5 2 X Additional Folders e Before new source files are added EX Property EI Peripheral Functions to the project we will create two 9 3 8 UR CG Tao Property CG Tutorial Drnia h additional folders in the CS B J R5F57 E Build CG Tutorial h h j Project Tree a Code Rebuild CG Tutorial e Inthe Project Tree pane righ
27. authorized for 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
28. buffer and callback function R SCI7 Serial Receive uint8 t amp g rx char 1 Enable SCI7 operations R SCI7 Start while 1U uintl6 t adc_result Wait for user requested A D conversion flag to be set SWl or SW2 if TRUE g adc trigger Call the function to perform an A D conversion adc result get adc Display the result on the LCD lcd display adc adc result R20UT3220EG0100 Rev 1 00 RTENESAS Page 45 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project Increment the adc_count and display using the LEDs if 16 adc count adc count 0 Send the result to the UART uart display adc adc count adc result Reset the flag g adc trigger FALSE x SW3 is directly wired into the ADTRG0n pin so will cause the interrupt to fire else if TRUE g adc complete Get the result of the A D conversion R_S12AD0_Get_ValueResult ADCHANNELO amp adc result Display the result on the LCD lcd display adc adc result Increment the adc count and display using the LEDs if 16 adc count adc count 0 Send the result to the UART uart display adc adc count adc result Reset the flag g adc complete FALSE End user code Do not edit comment generated here Then add the following function definition in the user code area at the end of the file pokoko
29. c void cb switch press void Check if switch 1 or 2 was pressed if g_switch_flag amp SWITCHPRESS_1 SWITCHPRESS_2 R20UT3220EG0100 Rev 1 00 RTENESAS Page 37 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project set the flag indicating a user requested A D conversion is required g_adc_trigger TRUE Clear flag g_switch_flag 0x0 BRK KKK KKK KK RK KKK KK RR KKK KK KK ck ck ck ck ck ck ck KK KK KK RK KR KK KKK KK End of function cb switch press Koko k k k k k k k k k k ok ok ok ok ok ok ok ok ok ok ok ok ok k kk k okok okok okok okok okok okok okok okok k k k k k k k k ke ee e x kk k k k k k k k k kok k k kk kk AA kk k k k k kk ko kk kk kk kk kk kk Sk Sk RK KK KK okok kk kkk kk kk Function Name get adc Description Reads the ADC result converts it to a string and displays it on the LCD panel Argument none x Return value uintl6 t adc value kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxk static uintl16 t get adc void A variable to retrieve the adc result uintl6 t adc result Stop the A D converter being triggered from the pin ADTRGOn R S12ADO Stop Start a conversion R S12ADO SWTriggerStart Wait for the A D conversion to complete while FALSE g adc complete Wait Stop conversion R S12ADO SWTriggerStop Clear ADC flag g adc complete
30. data endian little round to nearest round nearest Handles as zeros denormalize off Handles in single precision dbl size 4 No Handles as unsigned char unsigned char Handles as unsigned unsigned bitfield No Allocates from right bit_order right No unpack No noexception Nof tti off None fint register O Compiles within 24 bits branch 24 Base register for ROM None Base register for RAM None Address value of base register that sets the address value F 00000000 Register of base register that sets the address value None Build mode Selects the build mode name to be used during build 4 Source Language of the C source file C99 lang c99 C C89 lang c Language of the C source file Additional include paths System include paths Include files at the head of compiling units Macro definition Invalidates the predefined macro C99 lang c99 pste QUe parso Include files at the head of coi Macro definition 0 Select the Link Options tab at the bottom of the properties window pane Under Section gt ROM to RAM mapped section add the three mappings as shown opposite e These settings are easily added by clicking the button and pasting the following text into the dialog D R D 1 R 1 D 2 R 2 e This ensures that the linker assigns RAM rather than ROM addresses to C variables 4 Optimization ptimization type 4 Section Section start address No optimi
31. de Generation Using the CS plug in Output M0409002 The generating source folder is C Workspace CG_Tutorial M0409001 The following files were generated J M0409000 cg srcXr cg main c was generated d M0409000 cg srcXr cg dbsct c was generated d M0409000 cg srcXr cg intprg c was generated d M0409000 cg srcXr cg resetprg c was generated d M0409000 cg srcXr cg sbrk c was generated d M0409000 cg srcXr cg vecttbl c was generated d M0409000 cg srcXr cg sbrk h was generated d M0409000 cg srcXr cg stacksct h was generated d M0409000 cg srcXr cg vect h was generated d M0409000 cg srcXr cg hardware setup c was generated d M0409000 cg srcXr cg macrodriver h was generated d M0409000 cg srcXr cg userdefine h was generated d M0409000 cg srcXr cg cgc c was generated M0409000 cg srcXr cg cgc user c was generated d M0409000 cg srcXr cg cgc h was generated d M0409000 cg srcXr cg icu c was generated d M0409000 cg srcXr cg icu user c was generated d M0409000 cg srcXr cg icu h was generated d M0409000 cg srcXr cg port c was generated M0409000 cg srcXr cg port user c was generated d M0409000 cg srcXr cg port h was generated M0409000 cg srcXr cg cmt c was generated J M0409000 cg srcXr cg cmt user c was generated d M0409000 cg srcXr cg cmt h was generated M0409000 cg srcXr cg sci c was generated d M0409000 cg srcXr cg sci user c was generated d M0409000 cg srcXr cg sci h was generated d M0409000 cg srcXr cg sl2ad c was gen
32. e code is generated to set LEDS initially off erty a Peripheral Functions 9 Unused On Om O Pulp CMOS output v C Output 1 C High drive output P01 Unused In Out C Pulup cmos output Output 1 High drive output P02 Unsed Ol d d Pukp CMOS output C Output 1 High drive output P03 Unused In Out Pul up CMOS output V Output 1 V High drive output P05 Unused In Out Pulup CMOS output v W Output 1 Y High drive output P07 Unused Ond OO Pup CMOS output C Output1 C High drive output el Generate Code a O aroma Function me 38 JE 5 Lo ts Pori2 E ga Unused In Out Pull up CMOS output C Output 1 High drive output P21 Unused In Out Pul up CMOS output Outputi High drive output Unused In Out L Pull up CMOS output v Output 1 High drive output P23 Unused In Out Pulup CMOS output Output 1 High drive output P24 Unused In C Out Pull up CMOS output C Output 1 High drive output P25 Unused O In Out Pull up CMOS output I Output 1 C High drive output P26 Unused In Out Pull up CMOS output v V Output
33. eceiveend function void r sci7 callback receiveend void Start user code Do not edit comment generated here 2 iii End user code Do not edit comment generated here At the end of the file in the user code area for adding add the following function definition RR KR k k okok okok okok okok okok okok okok okok okok okok okok okok okok k k k k okok okok okok okok okok kk kk k k k k k k k k konkon I ko kk Function Name R SCI7 AsyncTransmit Description This function sends SCI7 data and waits for the transmit end flag x Arguments e tx bur transfer buffer pointer tx num buffer size Return Value status x MD_OK or MD_ARGERROR CK Ck kok kk kk kk kk kk kk kk k RARA RARA RARA RARA RARA RARA RARA RARA RARA RARA RARA RARA RARA MD STATUS R SCI7 AsyncTransmit uint8_t const tx buf const uintl6 t tx num MD_STATUS status MD_OK clear the flag before initiating a new transmission sci7 txdone FALSE Send the data using the API status R SCI7 Serial Send tx buf tx num Wait for the transmit end flag while FALSE sci7 txdone FE Wait return status BOR K K k k IKK I IKK ke kk ko ko kk I KK II ke ke kk kok RARA k ke k kk ke ko kk k kk k k k k k k k k k kk k k kk k k kk k k ke ke k k k k k End of function R SCI7 AsyncTransmit OKCKCKCkCk k kk dk kk kk KK ok okok okok ck ck ck kok kok kc kCkCkCkCkCkCkCk ck ck ck ck ck c
34. entiometer The RSK board contains all the circuitry required for microcontroller operation R20UT3220EG0100 Rev 1 00 AS Page 7 of 53 Jan 23 2015 RENES RSK RX71M 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 the project CS 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 Some of the illustrative screenshots in this document will show text in the form RXxxx These are general screenshots and are applicable across the whole RX family In this case simply substitute RXxxx for RX71M The tutorial examples in this manual assume that installation procedures described in the RSK Quick Start Guide have been completed Please refer to the Quick Start Guide for details of preparing the configuration These tutorials are designed to show you how to use the RSK
35. erated d M0409000 cg srcXr cg s12ad user c was generated d M0409000 cg srcXr cg s12ad h was generated d M0409003 The operation of generating file was successful d EOF Code E Output Error List Figure 4 16 Code generator console Figure 4 17 shows the Code Generator Files in the Project Tree pane ln the next section the CG Tutorial project will be completed by adding user code into these files and adding new source files to the project R20UT3220EG0100 Rev 1 00 EN ESAS Page 24 of 53 Jan 23 2015 RSK RX71M Project Tree 4 Gode Generation Using the CS plug in n 5d 5 R20UT3220EG0100 Jan 23 2015 CG Tutorial Project i Ex R5F571MLCxFC Microcontroller Code Generator Design Tool CC RX Build Tool RX Simulator Debug Tool File Tl Build tool generated files E Code Generator men e r_cg_intprg c a e r cg resetprg c r cg sbrk c See e r_cg_vecttbl c e r_cg_hardware_setup c e r cg cgc c e r cg cgc user c e r cg icu c e r cg icu user c e r cg port c r cg port user c A e r cg cmt c pe ej r Cg cmt user c e r cg sci c e r cg sci user c c r cg sl2ad c pon e r_cg_s12ad_user c h r cg sbrk h h r cg stacksct h A h r cg vect h h r_cg_macrodriver h h r cg userdefine h h r cg cgc h ma h r cg icu h v rcg porth h r cg cmt h h r cg sci h r c
36. erator node to expand the list Expand the Peripheral Functions node by clicking on the 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 CG Tutorial CS for CC Peripheral Functions EEE File Edit View Project Build Debug Tool Window Help Aa DAG X ABO o A8 A Ej E Detecta rl LTO NLO y i cz 31 3439 39 Project Tree AX a Peripheral Functions 2 9 28 ru LE PELA CG Tutorial Project fe Generate Code Tw d E a E Z c s O 0 0 0 o AS BT FE PE i aus B utorial Project 4 pem RSFS71MLC FC Microcontroller Clock setting On chip debug setting Block diagram a raj Code Generator Design Tool Main clock oscillator and RTCMCLK setting E A Pin View V Operation E E Peripheral Functions E Main clock oscillator forced oscillation 1 ori Fon Circuit Main clock oscillation source Resonator Mi Clock Frequency Accuracy N Frequency 24 MHz V Low Power Consumption Interrupt Controller Unit Oscillator wait time 11000 us Actual value 11090 909 ps 43j W4 Buses E Oscillation stop detection function Disabled c DMA Controller 87 Data Transfer Controller PLL circuit setting 87 Event Link Controller E Operation 1 0 Ports lain clock oscillator 3j Multi Function Ti
37. g sl2ad h Figure 4 17 Code Generator Files in the Project Tree Rev 1 00 RENESAS q x Page 25 of 53 RSK RX71M 5 Completing the Tutorial Project 5 Completing the Tutorial Project 5 1 Project Settings e In the Project Tree pane select aro CC RX Build Tool The build ist Det properties will appear in the main window e CS creates a single build configuration called Default Build for the project This has standard code optimisation turned on by default e 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 Instruction set architecture Uses floating point operation instructions Endian type for data Rounding method for floating point constant operations Handling of denormalized numbers in floating point constants Precision of the double type and long double type Replaces the int type with the short type Sign of the char type Sign of the bit field type Selects the enumeration type size automatically Order of bit field members Assumes the boundary alignment value for structure members is 1 Enables C exceptional handling function try catch and throw Enables the C exceptional handling function dynamic cast and typeid General registers used only in fast interrupt functions Branch width size RXv2 architecture isa rxw2 Yes fpu Little endian
38. generate a High priority interrupt every 1ms We will use this interrupt later in the tutorial to provide an API for generating high accuracy delays reguired in our application f Generate Code A O KS i Me HOA 0 OU BO See 7 IT BI TAK E CMTO curi CMT2 cura Compare match timer operation setting Unused Used m Count clock setting PCLK 8 PCLK 32 PCLK 128 PCLK 512 Interval value setting Interval value 1 ms w Actual value 1 Interrupt setting Y Enable compare match interrupt CMI0 Priority Level 10 Figure 4 5 CMTO tab Navigate to the CMT1 sub tab and configure CMT1 as shown in Figure 4 6 This timer is configured to generate a High priority interrupt after 20ms This timer is used as our short switch de bounce timer later in this tutorial R20UT3220EG0100 Rev 1 00 RTENESAS Page 16 of 53 Jan 23 2015 RSK RX71M 4 Code Generation Using the CS plug in Peripher laj E Peripheral Functions Es E Compare match timer operation setting Unused Count clock setting C PCLK 8 PCLK 32 PCLK 128 PCLK 512 Interval value setting Interval value v Actual value 20 Interrupt setting Enable compare match interrupt CMI1 Priority Level 10 Figure 4 6 CMT1 tab Navigate to the CMT2 sub tab and configure CMT2 as shown in Figure 4 7 This timer is configured to generate a High priori
39. k ck A KCKCKCKCKCKCk Ck ck ck ck ck ck ck ck ck ck kc k ck ck kk kkk kk ek R20UT3220EG0100 Rev 1 00 RENESAS Page 42 of 53 Jan 23 2015 RSK RX71M 5 Gompleting the Tutorial Project 5 6 2 Main UART code Open the file r cg main c Add the following declaration to the user code area for include near the top of the file Add the following declaration to the user code area for global near the top of the file Add the following highlighted code to the user code area in the main function void main void R MAIN UserInit Start user code Do not edit comment generated here Initialize the switch module R SWITCH Init Set the call back function when SWl or SW2 is pressed R SWITCH SetPressCallback cb switch press Initialize the debug LCD R LCD Init Displays the application name on the debug LCD R LCD Display 0 uint8 t RSK RX71M R LCD Display 1 uint8 t Tutorial R LCD Display 2 uint8 t Press Any Switch Start the A D converter R S12ADO Start while 1U Wait for user requested A D conversion flag to be set if TRUE g_adc_trigger uint16_t adc_result Call the function to perform an A D conversion adc result get adc Display the result on the LCD lcd display adc adc result rs bart display adc ade count ade remit Reset the flag g adc trigger FALSE R20UT3220EG0100 Rev
40. kokokokokokokokokokokok okok okok okok okok okok okokokok okok okok okok okok A A ko Function Name led display count Description Converts count to binary and displays on 4 LEDSO 3 Argument i uint8 t count Return value none CK Ck Ck k k ok kk Ck ok k k RRA kk okok k k Ck kk kok kk Ck ke kk okokok ok Ck kk okok k k ke kok kok kk kok kok kok k k kk ke kk k k kk ke ke ke static void led display count const uint8 t count Set LEDs according to lower nibble of count parameter LEDO count amp 0x01 LED_ON LED_OFF LED1 count amp 0x02 LED ON LED OFF LED2 count amp 0x04 LED ON LED OFF LED3 count amp 0x08 LED ON LED OFF BKK KK RK KK A RK kk Ck A koc k kk Ck Ck oko RR RO ROO RR RR ROO ARK I ARK I ARI I AOR KK k End of function led_display_count FER KI k kok o kok IK ok oke ok ok ok kk ok okok dk ok IK ok oke dk ok okok ok ke oke ok ok ke oke dk ok okok dk ok okok ok okok k ok okok ok ok okok okok okok IK I KK Select Build Project from the Build menu or press F7 CS will build the project with no errors The project may now be run using the debugger as described in 6 The code will perform the same but now the LEDs will display the adc count in binary form R20UT3220EG0100 Rev 1 00 RTENESAS Page 46 of 53 Jan 23 2015 RSK RX71M 6 Debugging the Project Debugging the Project e Inthe Project Tree pane right click the RX Simulator Debug T
41. le mode with no code optimisation Intermediate file output folder BuildModeName A 4 Frequently Used Options for Compie and will be using the Build mode to gt Additional include paths Additional include paths 2 create and debug the project gt System include paths System include paths 0 gt Macro definition Macro definition O Dutputs debugging information Yes debug O optimize 0 Dutputs additional information for inter module optimization ptimization type 1 optimize 1 Dutputs a source list file 2 optimize 2 4 Frequently Used Options for Assemble Max optimize max R20UT3220EG0100 Rev 1 00 ENESAS Page 27 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project e All of the sample code projects CC AXPropery ae contained in this RSK are BuildMode Build mode Debug configured with three Build modes CPU DefaultBuild Debug and E E i y i 4 OutputFile Type andPa Release Release IS created In Output file type Execute Module Load Module File the same way as above by lamedate kr eee E BuildModeName q 4 Frequently Used Options for Compi duplicating Default Build Additional include paths Additional include paths 2 Release build mode leaves code System include paths System include paths 0 A1 Macro definition Macro definition 0 optimisation turned on and Outputs debugging information No nodebug removes debug information from Optimiz
42. lications or use 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 f
43. llowing code in the in the user code area for global resulting in the code shown below Start user code for global Do not edit comment generated here End user code Do not edit comment generated here Insert the following code in the in the user code area of the r s12ad0 interrupt function resulting in the code shown below static void r_sl2ad0_interrupt void Start user code Do not edit comment generated here End user code Do not edit comment generated here Select Build Project from the Build menu or press F7 CS will build the project with no errors The project may now be run using the debugger as described in 6 When any switch is pressed the program will perform an A D conversion of the voltage level on the ADPOT line and display the result on the LCD panel Return to this point in the CG_Tutorial to add the UART user code R20UT3220EG0100 Rev 1 00 RENESAS Page 40 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project 5 5 Debug Code Integration API functions for trace debugging via the RSK serial port are provided with the RSK Refer to the Tutorial project folder created according to the Quick Start Guide procedure Locate the files r_rsk_debug h and r_rsk_debug c in this folder Copy these files into the C Workspace CG_Tutorial folder Import these two files into the project in the same way as the LCD files In the r_rsk_debug h file ensure the followi
44. lue 3 667 AN003 conversion time setting input sampling time 3 667 s Actual value 3 667 AN004 conversion time setting Input sampling time 3 667 lis Actual value 3 667 ANO05 conversion time setting input samping time 3667 us Actual value 3 657 AN006 conversion time setting Input sampling time 3 667 us Actual value 3 667 AN007 conversion time setting Input sampling time 3 667 s Actual value 3 667 Conversion time setting Total conversion time Group A 4 083 us Total conversion time Group B Note Continuous sampling is disabled Interrupt setting Enable AD conversion end interupt S12ADI0 Priority Level 15 highest TENESAS Page 18 of 53 Jan 23 2015 RSK RX71M 4 Code Generation Using the CS plug in 4 4 5 Serial Communications Interface Navigate to the Serial Communications Interface tab in Code Generator select the SCI6 sub tab and apply the settings shown in Figure 4 9 In the RSK RX71M SCI6 is used as an SPI master for the Okaya Pmod LCD on the PMOD1 connector as shown in the schematic a Peripheral Functions El Generate Code Z O dm a6 A oca 0 00 0 00 CL AT TM TRAM scie sc scii2 Asynchronous mode O Asynchronous mode Multi processor Clock synchronous mode gt Smart card interface mode gt Simple IIC bus 9 Simple SPI bus Pin setting TXD6 SMOSI6 SSDA6 Transmission Transmis
45. mer Pulse Wi Port Output Enable 3 3 General PWM Timer 31 87 16 Bit Timer Pulse Unit 4 Programmable Pulse Generz 240 i 8 Bit Timer 3 9 Compare Match Timer Sub clock oscillator and RTC RTCSCLK setting 33 87 Compare Match Timer W ID Operation a W Realtime Clock Drive ranaritu for low CI amp Watchdog Timer Output ax a Independent Watchdog Tim Information M0200002 The following plug ins are not enabled J 41 87 Serial Communications lnter Debug Console Plug in E 5 W Serial Communications Inter program Asatyzer Plos ind x DC Bus Interface IronPython Console Plug in Stack Usage Tracer Serial Peripheral Interface Update Manager Plug in W CRC Calculator LR n a al la bo iii 12 BitA D Converter All Messages 4 el Output Ei Error List Fi Fa F3 FY les FE F1 FH Fa FI rn Ha gis DISCONNECT 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 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 Project Tree gt Project Name gt 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 re
46. n De ee CR Mob mm ES RE AY So E 28 5 3 EGD Gode Integratior ee rr rr nee e o E rr nn rr On E EO 29 5 4 Switch Code Integration cesccceecceceeeceeeeeeeeeeeceeeeeeaaes ace entente trn enne nr nast trt s inten nnns sss ns entes nnne 33 5 5 Debug Code Integration sssessssssssssssseseseseenee nennen entente A KK KRKA trt sente aa Brari aa Ia a nene 41 5 6 UART Code Integrato Ma e ser a enira ep a aara A aA nnnm entre enn sedis si PAKA entes ensis nn nsa RK AEE 41 Bf J EDGode Integration io deeem p E e PEDE KS E OP OE C entem menie ET E 45 6 Debugging th OSC aie eot sekos the tetti Eu skono iA LAE e E EE 47 7 Running the Code Generator Tutorial coooonnnnccccnnnnnnnccnnnnnncccnnnnnnnnnnnnnnnnnnncncnnnnnnnnnnnns 48 7 1 RUN the Tuta 48 8 Additional Information eeseeseenesneelnnnknennnnnnnknnnnnnknnnnnnknnknsnannkanknntas 49 LENESAS RSK RX71M R20UT3220EG0100 Rev 1 00 RENESAS STARTER KIT Jan 23 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 provides an evaluation of 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 pot
47. n priority setting Group A priority Group A without priority v Group B action Not restarted or continued due to Group A priority S p E le AD conversion end interrupt for group B ST2GBADID Level 15 highest x Figure 4 8 A D Converter tab R20UT3220EG0100 Rev 1 00 AID converted value count setting Addition mode Average mode Analog input channel setting Convert Group A Convert Group B Add Average AD value Dedicated sample and hold ANO00 ivi a F F E AN001 O O L AN002 aj O O E AN003 r1 r1 AN004 laj E AN005 FI O F AND06 El O C AN007 O B Conversion start trigger setting Conversion start trigger Group A A D conversion start trigger pin Canva art trigger Group B E Compare match with or input capture to MTUO TGRA ADTRGO pin selection Pe AD converted value addition count 1 time conversion Data placement Right alignment Automatic clearing Disable automatic clearing Data accuracy C2btacuacy Dedicated sample and hold circuit setting Input sampling time fg ls The input value is invalid ANQ00 Self diagnosis conversion time setting Input sampling time 3 667 us Actual value 3 667 ANOO1 conversion time setting Input sampling time 3 667 us Actual value 3 667 AN002 conversion time setting Input sampling time 3 667 ps Actual va
48. nd product How to Use This Manual 1 Purpose and Target Readers This manual is designed to provide the user with an understanding of how to use Application Leading Tool 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 RX71M 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 RX71M 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 Description Document Title Document No Type User s Manual Describes the technical details of the RSK RX71M User s Manual R
49. ng macro definition is included This macro is referenced in the r_rsk_debug c file and allows easy re direction of debug output if a different debug interface is used 5 6 UART Code Integration 5 6 1 SCI Code In the CS Project Tree expand the Code Generator folder and open the file r_cg_sci h by double clicking onit Insert the following code in the user code area at the end of the file Start user code for function Do not edit comment generated here MD STATUS R_SCI6_SPIMasterTransmit uint8_t const tx buf const uint16 t tx num End user code Do not edit comment generated here Open the file r cg sci user c Insert the following code in the user area for global near the beginning of the file Start user code for global Do not edit comment generated here Flag used locally to detect transmission complete static volatile uint8 t sci6 txdone End user code Do not edit comment generated here In the same file insert the following code in the user code area inside the r sci7 callback transmitend function static void r sci7 callback transmitend void Start user code Do not edit comment generated here End user code Do not edit comment generated here 4 R20UT3220EG0100 Rev 1 00 RENESAS Page 41 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project In the same file insert the following code in the user code area inside the r sci7 callback r
50. nt 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 subseguent code generation operations This is useful if after adding custom code the user needs to re visit Code Generator to change any MCU operating parameters The CG Tutorial project uses interrupts for switch inputs the ADC module the Compare Match Timer CMT the Serial Communications Interface SCI and uses these modules to perform A D conversion and display the results via the Virtual COM port to a terminal program and also on the LCD display on the RSK Following a tour of the key user interface features of Code Generator in 4 3 the reader is guided through each of the peripheral function configuration dialogs in 4 4 In 5 the reader is familiarised with the structure of the template code as well as how to add their own code to the user code areas provided by the code generator 4 2 Enabling Code Generator After installation of CS Code Generator must be enabled This step is only reguired once CS will remember this setting on subseguent 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 F
51. o filter 0 Low level v Priori Level 15 highest IRQ5 setting v IRG5 Pin P15 Digtalfiter No filter lo Valid edge Falling Prorty Level 15 highest Figure 4 3 Interrupt Functions tab Navigate to the Group Interrupts sub tab and ensure that the Group BLO interrupt is selected as shown in Figure 4 4 The Group BLO interrupt is used for SCI Transmit End Interrupts TEI and Reception Error Interrupts ERI as described in 4 4 5 R20UT3220EG0100 Rev 1 00 RTENESAS Page 15 of 53 Jan 23 2015 RSK RX71M 4 Code Generation Using the CS plug in Z Property Zi Peripheral Functions x fe Generate Code Z I d im o A SOO OAO DODAT TNT 5 General Group Interrupts Interrupt B A selection b Group BEQ setting 7 Group BEO Priority Level 15 highest Group BLO setting V Group BLO Priority Level 15 highest Group BL1 setting E Group BL1 P Level 15 highest Group ALO setting Group ALO Priori Level 15 highest Group AL1 setting Group AL1 Priori Level 15 highest Figure 4 4 Group Interrupt Functions tab 4 4 3 Compare Match Timer Navigate to the Compare Match Timer node in Code Generator CMTO will be used as an interval timer for generation of accurate delays CMT1 and CMT2 will be used as timers in de bouncing of switch interrupts In the CMTO sub tab configure CMTO as shown in Figure 4 5 This timer is configured to
52. ocal Casting to ensure use of correct data type a char adc count amp 0x000F uart buffer 4 char a lt Ox0A a 0x30 a 0x37 a char adc result s 0x0F00 gt gt 8 uart buffer 14 char a lt 0x0A a 0x30 a 0x37 a char adc result 8 0x00F0 gt gt 4 uart buffer 15 char a lt 0x0A a 0x30 a 0x37 a char adc result amp 0x000F uart buffer 16 char a lt 0x0A a 0x30 a 0x37 Send the string to the UART R DEBUG Print uart buffer BRK KK okok KK KK ok oke dk ok ok oka ok ok oke ka ok ok oke k ok oke oka ok ok oke oka ok ok oke oka ok oke k ok ok kok ok ok oka ok ok oke k ok ok kok ok ok k ok ok kok ok ok k ok ok okok ok ok okok okok okok x End of function uart display adc KCKCKCk Ck k kok k oka ok oke oka ok ok oke k ok ok oka ok ok oke kok k k ok oke k ok ok oke k ok ok oka k ok oke k ok ok oke da ok ok oka ok ok kok ok ok oke oka ok ok oka ok ok kok ok okok ok okok RARA I Select Build Project from the Build menu or press F7 CS will build the project with no errors R20UT3220EG0100 Rev 1 00 RTENESAS Page 44 of 53 Jan 23 2015 RSK RX71M 5 Gompleting the Tutorial Project The project may now be run using the debugger as described in 6 Connect the RSK G1CUSBO 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 aut
53. ollowing terms The 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 conseguential 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
54. omatically Open Device Manager the virtual COM port will now appear under Port COM 8 LPT as RSK USB Serial Port COMx where x is a number Open a terminal program such as HyperTerminal on the PC with the same settings as for SCI7 see 4 4 5 When any switch is pressed or when c is sent via the COM port the program will perform an A D conversion of the voltage level on the ADPOT line and display the result on the LCD panel and send the result to the PC terminal program via the via SCI7 Return to this pointin the CG Tutorial to add the LED user code 5 7 LED Code Integration Open the file r cg main c Add the following declaration to the user code area for include near the top of the file Add the following declaration to the user code area for global near the top of the file Add the following highlighted code to the user code area in the main function void main void R MAIN UserInit Start user code Do not edit comment generated here Initialize the switch module R SWITCH Init Set the call back function when SW1 or SW2 is pressed R SWITCH SetPressCallback cb switch press Initialize the debug LCD R LCD Init Displays the application name on the debug LCD R LCD Display 0 uint8 t RSK RX71M R LCD Display 1 uint8 t Tutorial R LCD Display 2 uint8 t Press Any Switch Sart the A D converter R S12ADO Start Set up SCI7 receive
55. ool Select Using Debug Tool gt RX E1 JTAG ff CG Tutorial Project E R5F571MLCxFC Microcontroller ca 5 Code Generator Design Tool i A CC RX Build Tool RX Simulator DeF Using Debug Tool 4 Internal ROM RAM Size of internal ROM KByte Size of internal RAM KBytes 4 Endian RX E1 Serial m lll asta fer gt PL RXE20 Serial e Double click RX E1 JTAG Debug Tool to display the debugger tool properties Under Clock change ex RXEI JTAG Property 4 Internal ROM RAM E Size of internal ROM KBytes 4096 a DES ireguengy Size of internal RAM KBytes 552 operating Pesos lo Size of DataFlash memory KBytes 64 4 Clock e All other settings can remain at a cn EXTAL their defaults Ep r 24 0000 Operating freguency MHz 240 0000 Allow changing of the clock source on wri No 4 Connection with Emulator 4 Connection with Target Board Power target from the emulator MAX 200 No Communications method JTAG JTAG clock MHz 16 5 e Connect the El to the PC and the RSK E1 connector Connect the 5V PSU to the PWR connector on the RSK Connect the Okaya Pmod LCD to the PMOD1 connector From the Debug menu select Download to start the debug session and download code to the target R20UT3220EG0100 Rev 1 00 RENESAS Page 47 of 53 Jan 23 2015 RSK RX71M 7 Running the Code Generator Tutorial 7 Running the Code Generator Tutorial
56. quired function in the Project Tree gt Project Name gt Code Preview on the left R20UT3220EG0100 Rev 1 00 RENESAS Page 12 of 53 Jan 23 2015 RSK RX71M 4 Code Generation Using the CS plug in 4 4 Code Generation In the following sub sections the reader is guided through the steps to configure the MCU for a simple project containing interrupts for switch inputs timers ADC and a UART 4 4 1 Clock Generator Figure 4 2 shows a screenshot of Code Generator with the Clock Generator function open Click on the Clock setting sub tab Configure the system clocks as shown in the figure In this tutorial we are using the on board 24 MHz crystal resonator for our main clock oscillation source and the PLL circuit is in operation The PLL output is used as the main system clock and the divisors should be set as shown in Figure 4 2 R20UT3220EG0100 Rev 1 00 RENESAS Page 13 of 53 Jan 23 2015 RSK RX71M 4 Code Generation Using the CS plug in Sl Peripheral Functions lai Aza A 5550 MT TNP E fe Generate Code I Cock seting Bock diagram Main clock oscillator and RTCMCLK setting Operation Main clock oscillator forced oscillation only for RTC software standby and deep software standby mode Main clock oscillation source Resonator Frequency 24 MHz Oscillator wait time 11000 us Actual value 11090 909 us Oscillation stop detection function
57. r and open the file r cg userdefine h by double clicking on it Insert the following code the user code area resulting in the code shown below Start user code for function Do not edit comment generated here define TRUE 1 define FALSE 0 End user code Do not edit comment generated here R20UT3220EG0100 Rev 1 00 RENESAS Page 35 of 53 Jan 23 2015 RSK RX71M 5 Gompleting the Tutorial Project Open the file r cg main c and insert include r rsk switch h in the user code area for include resulting in the code shown below Start user code for include Do not edit comment generated here include r okaya lcd h End user code Do not edit comment generated here Next add the switch module initialization function call highlighted in the user code area inside the main function resulting in the code shown below void main void R MAIN UserInit Start user code Do not edit comment generated here Initialize the debug LCD R LCD Init Displays the application name on the debug LCD R LCD Display 0 uint8 t RSK RX71M R LCD Display 1 uint8 t Tutorial R LCD Display 2 uint8 t Press Any Switch while 1U End user code Do not edit comment generated here In the same file insert the declarations in the user code area for global resulting in the code shown below Start user code for global Do not edit comment generated here
58. rial Project Start user code for global Do not edit comment generated here End user code Do not edit comment generated here In the CS Project Tree open the file r_cg_main c by double clicking on it Insert include r_okaya_Icd h in between the user code delimiter comments as shown below Start user code for include Do not edit comment generated here End user code Do not edit comment generated here Scroll down to the main function and insert the highlighted code as shown below into the beginning of the user code area of the main function void main void R MAIN UserInit Start user code Do not edit comment generated here while 1U End user code Do not edit comment generated here R20UT3220EG0100 Rev 1 00 RENESAS Page 30 of 53 Jan 23 2015 RSK RX71M 5 Gompleting the Tutorial Project 5 3 1 SPI Code The Okaya LCD display is driven by the SPI Master that was configured using Code Generator in 4 4 5 In the CS Project Tree open the file r cg sci h by double clicking on it Insert the following code in the user code area at the end of the file Start user code for function Do not edit comment generated here End user code Do not edit comment generated here Now open the r cg sci user c file and insert the following code in the user area for global Start user code for global Do not edit comment generated here
59. rskrx71mdef h r rsk switch h and r_rsk_switch c in this folder Copy these files into the C Workspace CG_Tutorial folder Import these three files into the project in the same way as the LCD files The switch code uses interrupt code in the files r_cg_icu h r_cg_icu c and r_cg_icu_user c and timer code in the files r_cg_cmt h r_cg_cmt c and r_cg_cmt_user c as described in 4 4 2 and 4 4 3 It is necessary to provide additional user code in these files to implement the switch press release detection and de bouncing required by the API functions in r_rsk_switch c 5 4 1 Interrupt Code In the CS Project Tree expand the Code Generator folder and open the file r_cg_icu h by double clicking onit Insert the following code in the user code area at the end of the file Start user code for function Do not edit comment generated here End user code Do not edit comment generated here R20UT3220EG0100 Rev 1 00 RENESAS Page 33 of 53 Jan 23 2015 RSK RX71M 5 Gompleting the Tutorial Project Now open the r cg icu c file and insert the following code in the user code area at the end of the file kok k k ke e k KKK KKK Function Name Description Arguments Return Value kkkkkkkkkkkkkkbkkkkkkkkkkkkkkkkkkkkkkkbkkkkkkkkkkkkkkbkkkkkkkkkkkkik R ICU IRQIsFallingEdge This function returns 1 if the specified ICU IRO is set to falling edge triggered otherwise 0 uint8 E irq no if f
60. sion Transmission Transmission Master transmit only r PO1 Poo m m Figure 4 9 SCI6 General Setting tab Select the SCI6 Setting sub tab and configure the SPI Master as illustrated in Figure 4 10 Make sure the Transfer direction setting is set to MSB first and the Bit rate is set to 1500000 All other settings remain at their defaults R20UT3220EG0100 Rev 1 00 Jan 23 2015 RENESAS Page 19 of 53 RSK RX71M 4 Code Generation Using the CS plug in rty Zi Peripheral Functions i BABGADBIDBISAJ scio scii sci scia scia scis scie sciz scii2 amp Bit Timer General seting Seting Transfer direction setting LSBfirst MSBfirst Data inversion setting Normal Inverted Transfer rate setting Transfer clock Internal clock P02 Bit rate 1500000 bps Actual value 1500000 Error 0 Enable modulation duty correction 255 SCK6 pin function selection Clock output Clock setting Clock delay Clock is not delayed Enable clock polarity inversion Data handling setting Transmit data handling Data handled in interrupt service routine Interrupt setting TXI6 priority Level 15 highest TEIS ERIS priorty Group BLO Level 15 highest Callback function setting Transmission end NI Figure 4 10 SCI6 SPI Master Setting Staying in the Serial Communications In
61. t adc result amp 0x00F0 gt gt 4 lcd buffer 7 char a lt Ox0A a 0x30 a 0x37 a uint8 t adc result amp 0x000F lcd buffer 8 char a lt Ox0A a 0x30 a 0x37 R20UT3220EG0100 Rev 1 00 ENESAS Page 38 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project Display the contents of the local string lcd_buffer R LCD Display 3 uint8 t lcd buffer KOK kk k kk k okok k koko kk k kk k koko okok kok KA hk KA k ok kkk kok k KA k kk k kok kok kok kkk kk kk ko ke kk ke ek End of function lod display ade FOR RR RO KKK RR CK XX K RR ROTO ROO RR kA K KA kk Ck A koc kk Ck kk koc k kk RARA kk KK I A Open the file r cg s12ad h by double clicking on it Insert the following code in the in the user code area for function resulting in the code shown below Start user code for function Do not edit comment generated here End user code Do not edit comment generated here Open the file r cg s12ad c by double clicking on it Insert the following code in the in the user code area for adding at the end of the file resulting in the code shown below Start user code for adding Do not edit comment generated here End user code Do not edit comment generated here R20UT3220EG0100 Rev 1 00 RTENESAS Page 39 of 53 Jan 23 2015 RSK RX71M 5 Completing the Tutorial Project Open the file r_cg_s12ad_user c and insert the fo
62. t click 2 I Clean GG Tutorial the CG Tutorial project and select o 13 File E Open Folder with Explorer Add gt Add New Category El Windows Explorer Menu Add gt A Add Subproject tis Set CG Tutorial as Active Project Add New Subproject PD Save Project and Development Tools as Package LY Add File Bil Paste Ctrl V E Add New File Past ct ale Rename F2 n Add New Category Property e Rename the newly created New L CG Tutorial Project Category folder to C Source Files P RSFSTIMLCxFC Microcontroller Repeat these steps to create a new t T Code Generator Design Tool Ay CC RX Build Tool gx RX Simulator Debug Tool amp D File E Build tool generated files AS iodefine h Code Generator C Source Files category folder for Dependencies R20UT3220EG0100 Rev 1 00 RTENESAS Page 28 of 53 Jan 23 2015 RSK RX71M 5 3 LCD Code Integration API functions for the Okaya LCD display are provided with the RSK 5 Completing the Tutorial Project Refer to the Tutorial project folder created according to the Quick Start Guide procedure Locate the files ascii h r okaya Icd h ascii c and r okaya lcd c in this folder Copy these files into the CAWorkspacelCG Tutorial folder Right click on the C Source Files in the Project Tree and select Add gt Add File Browse to the files ascii c and the folder r okaya lcd c in CAWorkspacelCG
63. terface tab in Code Generator select the SCI7 sub tab and apply the settings shown in Figure 4 11 In the RSK RX71M SCI7 is connected via a Renesas RL78 G1C to provide a USB virtual COM port as shown in the schematic Peripheral Functions EI pg Ss giz zZzsDADBDBADA SCI2 sci3 scia SCI5 scie SCIZ sci12 9 Asynchronous mode Transmission reception Asynchronous mode Multi processor Transmission Clock synchronous mode Transmission C Smart card interface mode Transmission v O Simple IIC bus Simple SPI bus Slave transmit receive v Pin setting RXD7 SMISO7 SSCL7 P92 TXD7 SMOSI7 SSDA7 P90 Y A E m r Figure 4 11 SCI7 General Setting tab R20UT3220EG0100 Rev 1 00 EN ESAS Page 20 of 53 Jan 23 2015 RSK RX71M 4 Code Generation Using the CS plug in Select the SCI7 Setting sub tab and configure SCI7 as illustrated in Figure 4 12 Make sure the Start bit edge detection is set as Falling edge on RXD7 pin and the Bit rate is set to 19200 bps All other settings remain at their defaults Peripheral Functions Generate Code E d gb E pase uo 949 Sari bit edge detection selling Low level on RXD7 pin Falling edge on RXD7 pin Data length setting 9 bits Bbits 7bits Parity setting None E
64. terface Specification PLL Phase locked Loop RAM Random Access Memory ROM Read Only Memory RSK Renesas Starter Kit RTC Realtime Clock SAU Serial Array Unit SCI Serial Communications Interface SPI Serial Peripheral Interface TAU Timer Array Unit TFT Thin Film Transistor TPU Timer Pulse Unit UART Universal Asynchronous Receiver Transmitter USB Universal Serial Bus WDT Watchdog timer All trademarks and registered trademarks are the property of their respective owners Table of Contents po PCIE 7 1 1 PUPOSE ER A a N 7 te ESTOS ien n d ee Re qu at Ido 7 2 IME OOUCHOM su coat etate b Or id 8 Sc Project Cr ation MIU S Fa sot xoa iate ipti ie iia 9 3 1 INTOQUCION el 9 3 2 Creating the Projector oci me LLL DO send pate ewan MER cer ep lee Pep ventra a de 9 4 Code Generation Using the CS plug in 11 4 1 INTO UCI EM PER 11 4 2 Enabling Code Generator esee eee eee eee eee ohne KK en nentes sn nnns sn AKE KRKA nnns innen senten nnns 11 43 Code Generator OU redes A ka san De Eie eoo DaF a ikan edo prp e aeg uo 12 4 4 Gode Generatioh iiie e Ee Lea ERR sen Eae iia praia 13 5 Completing the Tutorial Project o ooooooocccccnnnccccnnicanoccccncnccnnnnnnnanonnnnnnnnncnnnnnnnnnnncnnnnncnnnnnnnns 26 531 Project Settings ee te e eit Kn Bara ph teet ene Ded ERR nro s nakl afl Erao end ey ut Uude Rao 26 De Additional Folders ere p ere ren te eme pep pn rn mn GG Raa RT pn mop n
65. ty interrupt after 200ms This timer is used as our long switch de bounce timer later in this tutorial Sil Peripheral Functions Le Generate Code mj e 4 m d i 1 gt HE wu db curo cri cuz cura a Compare match timer operation setting d Unused Count clock setting PCLK 8 PCLK 32 PCLK 128 Interval value setting Interval value v Actual value 200 004267 Interrupt setting Enable compare match interupt CMI2 Priority Level 10 Figure 4 7 CMT2 tab 4 4 4 12 bit A D Converter Navigate to the 12 bit A D Converter tab in Code Generator Refer to the screenshot shown in Figure 4 8 and configure the S12ADO as shown We will be using the S12AD0 in 12 bit one shot mode on the AN000 input which is connected to the RV1 potentiometer output on the RSK The conversion start trigger will be via the pin connected to SW3 R20UT3220EG0100 Rev 1 00 EN ESAS Page 17 of 53 Jan 23 2015 RSK RX71M Peripheral Functions 4 Code Generation Using the CS plug in Unused Operation mode setting Single scan mode 7 Group scan mode Continuous scan mode Double trigger mode setting Disable Enable Self diagnosis setting Mode Unused Voltage used Use VREFHOxO Disconnection detection assist setting Charge setting Unused Penod 1 ADCLK Group sca
66. unction Module Name Description i Code Generator Plugin Plugin to generate the device driver automatically for V850 78K0 78KOR RL78 G12 G13 G1 V Code Generator PinView Plug in Plug in 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 ES Property Vi Taj Y 2 ei Code Generator Property f cc Tutorial Project 4 Generale File Mode BE R5F571MLCxFC Microcontroller Pin View File generation control El Peripheral Functions Register files H E Code Preview Report type f AL CC RX Build Tool 4 Product informaton gt RX Simulator Debug Tool 3 13 File R20UT3220EGO100 Rev 1 00 RENESAS Page 11 of 53 Jan 23 2015 RSK RX71M 4 Code Generation Using the CS plug in 43 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 Gen
67. ven Odd Stop bit length setting 1bit 2bits Transfer direction setting LSB4irst MSBHirst Transfer rate setting Transfer clock Internal clock PI Bit rate 19200 hd bps Actual value 19230 769 Error 0 16 Enable modulation duty correction 255 SCK7 pin function SCK7 is not used v Noise filter setting Enable noise filter Noise filter clock Clock signal divided by 1 60000000 Hz Hardware flow control setting None CTS RTS CTS7 RTS7 pin P93 Data handling setting Transmit data handling Data handled in interrupt service routine Receive data handling Data handled in interrupt service routine Interrupt setting TXIZ priority Level 15 highest RXI7 priority Level 15 highest Enable error interrupt ERIT TEI7 ERIT priority Group BLO Level 15 highest Callback function setting Transmission end Reception end Reception error m R20UT3220EG0100 Rev 1 00 Jan 23 2015 Figure 4 12 SCI7 Asynchronous Setting EN ESAS Page 21 of 53 RSK RX71M 4 Code Generation Using the CS plug in 4 4 6 VO Ports Referring to the RSK schematic LEDO is connected to P03 LED1 is connected to PO5 LED2 is connected to P26 and LED3 is connected to P27 Navigate to the I O Ports tab in Code Generator and configure these four I O lines as shown in Figure 4 13 and Figure 4 14 below Ensure that the Output 1 tick box is checked This ensures that th
68. ze NOOPtimize The specified section that outputs The specified section that outputs externally defined symbols to tF Section alignment 4 ROM to RAM mapped section 0 D R 1 D 1 R 2 D 2 R 1 2 Section alignment 0 ROM to RAM mapped section 3 LI R20UT3220EG0100 Rev 1 00 Jan 23 2015 RENESAS Page 26 of 53 RSK RX71M 5 Completing the Tutorial Project e From the Build menu select Build Build Mode Settings Sa Mode Settings Click Duplicate and in the resulting Character Selected build mode String Input dialog enter Debug for the name of the duplicate build mode Build mode list e The new Debug build mode will be 4 cc x Property added to the Build mode list Click ECT Close Now in the main CC RX ENTE Def tBuld Property window under the 4 OutputFile Type and Path Default Build Common Options tab click on the Output file type line containing Build Mode click Intermediate file output folder the pull down arrow and select Debug from the pull down e Inthe Frequently Used Options for EC RX Property aj e El 4 BuildMode Compile _ group select the Optimization Level option and CPU ry PIC PID select 0 from the pull down We dyes peur sus have now created a Debug build Output file type Execute Module Load Module Fi

Download Pdf Manuals

image

Related Search

Related Contents

Majestouch Convertible 2 取扱説明書PDF(72ページ・9.2MB)  Handbuch für Software und drahtlose Verbindung  9933 TableWare User's Guide.vp  Tripp Lite SmartPro 120V 500VA 300W Line-Interactive UPS, SNMP, Webcard, 1U Rack/Tower, USB, DB9 Serial  POWERCUT 650  LG AS-W1838*H0 User's Manual  Samsung SGH-B500 Εγχειρίδιο χρήσης  Trekstor DataStation duo w.ub, external, USB 2.0, 2TB  M-Patch V2 - SM Pro Audio  V7 Professional HD Webcam 720P  

Copyright © All rights reserved.
Failed to retrieve file