Home

Renesas Starter Kit for RL78/G13 Software Help Manual

image

Contents

1. 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 High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems safety equipment and medical equipment not specifically designed for life support Specific Aircraft aerospace equipment submersible repeaters nuclear reactor control systems medical equipment or systems for life support e g artificial life support devices or systems surgical implantations or healthcare intervention e g excision etc and any other applications or purposes that pose a direct threat to human life 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 Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have spe cific characteristics such as the occurrence of failure at
2. The simulated EEPROM s internal address pointer will auto increment with each byte written during the transfer DEVICE w WRITE DATA WRITE DATA WRITE DATA ADDRESS N 2 N 1 N 2 3 Read Operation The read operation will always start from a specified internal simulated EEPROM memory pointer and auto increment to the next byte until the address reaches the maximum value and a stop condition is detected The EEPROM slave should then reply with an ACK signal and send the data located at the current memory location and auto increment the internal pointer to the next byte location ln order to read another byte the master should send an ACK signal The master should repeat this un til 8 bytes have been read and should end the operation with a stop condition DEVICE R N READ DATA N READ DATA ADDRESS N 1 N Make the following connections between the RSKRL78G13 and the slave device SDAAO JA1 pin 25 gt Device SDA SCLAO JA1 pin 26 lt gt Device SDA R20UT0746EG 0100 Rev 1 00 RENESAS Page 18 of 27 Jun 21 2011 RL78G13 5 Peripheral Samples CON 5V JAl pin25 lt gt Device Vcc Ov JA1 pin 25 lt gt Device Vss Note Use a 4 7KO pull up resistor on the data and clock line 5 8 3 Operation All peripherals and modules are configured prior to the program calling the main function The sample initialises the LCD module and displays IIC Slav on the first line 3 The sample then c
3. 17 5 7 1 Description so decks RE ie these ee E A EO AO 17 5 7 2 Operations crs e e E acess cts dae ess E e kre e Soke CEA 17 TA A Tr E E or 1 TTA TTT TTT TTT TTTTTTTTTETTTE 18 5 8 1 Description A is eek eae a e o y its 18 5 8 2 TI Slave Commands Ere E TITT ITI TTT TTT TITT TTITTTTET ERT 18 5 8 3 Operation zu ao o nee eeru 19 5 90 kiem ker emen men pre mar prp rm mp a prr Gai rr e ial or eevee 19 5 9 1 DGS Crip tii sk o Ao e E o ties eal RAEI kad kaj 19 5 9 2 Operation enco EET SUE UEL SI SIO SKO ELEKTAJ 19 Di LOB DMACI SP E o o um RON KIN NN A AO 20 5 10 1 Descriptif ss a a ne Se ee o Kario 20 5 102 OpeTatlon ixxi uis o sme SEE EDE EN EE LN NUL DI E No 20 olo NDI kris A st A elo o sm en bo sn A a son ed 20 5 11 1 DCS CHIU OM sf osre TTI 20 5 11 2 Operation sas GN NE GE ENIO NDA EKS 21 AN UE EK err po korkoro o ro KPD Oro TU POO NUNO PO PO UO PO ARO PO OPO iJ 21 5 12 1 De dl ee 21 o 1222 Operation Ss snr e A o pe nb enk p Nen pto o ole idanto 21 Se3 E Headed aad eases MA No A KEN 21 5 13 1 Descriptions sss de TASTE ASI SKETO 21 513 2 Operalon sss ue SUSAN Sa GK ROLOS EN AO AARTS RADIA pan 22 6 AdditionaAl nifoTIMAON 3 2 sedis eetere regos lakes ada di 23 LENESAS RSKRL78G13 R20UTO746EG 0100 Rev 1 00 RENESAS STARTER KIT Jun 21 2011 1 Overview 1 1 Purpose This RSK is an evaluation tool for Renesas microcontrollers This manual explains the operation of t
4. R20UT0746EG 0100 Rev 1 00 a2 AS Page 14 of 27 Jun 21 2011 XENES RL78G13 5 Peripheral Samples 5 2 2 Operation 1 All peripherals and modules are configured prior to the program calling the main function The A D channel connected to the potentiometer is initially configured for 10 bit precision operations The sample first initialises the debug LCD and displays the name of the sample The sample then enables the external interrupts connected to the user switches SW1 and SW3 The sample then starts the ADC and the periodic timer channel The sample then waits in an infinite while loop and the rest of the sample s functionality is completed through interrupts 6 On completion of an A D conversion the A D interrupt handler is called It checks to see which user switch was last pressed before saving the A D result using the appropriate forma being 10 bit or 8 bit 7 When user switch SW1 is pressed the corresponding external interrupt handler The handler changes the pre cision mode to 8 bits and sets a flag to indicate that user switch SW1 was pressed 8 When user switch SW3 is pressed the corresponding external interrupt handler The handler changes the pre cision mode to 10 bits and sets a flag to indicate that user switch SW3 was pressed 9 The timer channel s interrupt handler is called on each timer overflow The A D integer result is converted and stored in a specially arranged string in a buffer array before being disp
5. Fax 886 2 8175 9670 Renesas Electronics Singapore Pte Ltd harbourFront Avenue 06 10 keppel Bay Tower Singapore 098632 Tel 65 6213 0200 Fax 65 6278 8001 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 11F Samik Lavied or Bldg 720 2 Yeoksam Dong Kangnam Ku Seoul 135 080 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 2010 Renesas Electronics Corporation All rights reserved Colophon 1 0 RL78 G13 Group TENESAS Renesas Electronics Corporation R20UT0746 0100
6. a certain rate and malfunctions under certain use conditions Further Renesas Electronics products are 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 ofa 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 system manufactured by you Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibil ity 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 This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics Please contact a Renesas Electronics sales office if you have any questions regarding the information cont
7. and TAU channel before entering an infinite while loop All subsequent operations are handled by interrupts 4 The ADC continuously converts the voltage set by the potentiometer and the result is stored in a global variable gWDT Period Updater within the ADC s interrupt handler The TAU channel s interrupt handler is called on every count overflow It stops the channel s count checks if the less than 75 of the period and restarts the WDT s count if this is true The TAU channel s period is updated using the ADC result multiplied by a factor of 58 The user LEDs states are toggled and the TAU channel s counting is restarted Turning the potentiome ter clockwise will reduce the user TAU channel s period and user LEDs flashing rate eventually resulting to the TAU channel s period being greater than the WDT s and resulting in the WDT reaching 75 and generat ing an interrupt The WDT interrupt handler stops the ADC and TAU operations displays 75 on the second line of the debug LCD before entering an infinite while loop To prevent the WDT causing a device reset the WDT s count is restarted within the loop 5 Reset the RSK to restart the test 5 12 RTC 5 12 1 Description This sample demonstrates usage of the RTC Real Time Clock with the time displayed on the debug LCD The RTC is configured to use the sub clock to generate 1 Hz periodic interrupts and output a 1Hz signal on the RTCIHZ pin which is also multiplexed w
8. interrupt level 5 As long as power supply is maintained above 4 06 Volts the period timer will generate interrupts which will synchronously flash all user LEDs The timer s interrupt handler checks the status of a user defined flag indi cating user LEDs synchronisation If the flag was set user LEDs LEDO LED2 are toggled to synchronise the LEDs with LED3 The second line of the debug LCD is cleared before all user LEDs states are toggled 6 On detection of a low power supply the LVD interrupt handler is called It stops the timer and displays De tected on the second line of the debug LCD if the LVD flag is set and turns off user LEDs LEDO LED2 LED3 is left turned on with the user defined synchronisation flag cleared to indicate that the user LEDs are not synchronised The timer is re started 5 7 IIC Master 5 7 1 Description This sample demonstrates usage of the IIC unit in master mode by performing read and write operations to an EEPROM memory device or an RSKRL78G13 running the IIC Slave sample The sample is configured to work with 8 bit word addressed EEPROM devices A total of 8 data bytes are transferred to the slave device starting from slave memory location 0 When writing to an EEPROM memory device the second data is incremented after each write from 0 to 9 For writes to a slave RSKRL78G13 the second data byte is incremented instead The sample is configured for communication with an EEPROM memory device To use an
9. press SW1 The sample then calls the DMAC DataTransfer function which configures the DMAC and channel 0 of SAUO The SAUO s channel 0 is configured for transmission with each transmitted data byte transferred to memory by the DMAC inside a while loop A total transfer of 512 bytes takes place before the loop is exited All user LEDs are turned off once the transfer ends The second line of the LCD module will display END The sample then enters an infinite while loop Stop the program execution and observe the memory contents Memory locations OxFFA00 OxFFBFF should be filled up with the string Renesas RL78G13 WDT 5 11 1 Description This sample demonstrates usage of the WDT Watch Dog Timer The WDT has been configured to generate an interrupt when the timer s count reaches 75 of its period A TAU channel is configured to generate periodic inter rupts whose period varies with the ADC value set by the potentiometer s positioning and restart the WDT s count Before executing the program ensure the potentiometer is turned fully counter clockwise R20UT0746EG 0100 Rev 1 00 RENESAS Page 20 of 27 Jun 21 2011 RL78G13 5 Peripheral Samples 5 11 2 Operation 1 All peripherals and modules are configured prior to the program calling the main function The sample initialises the LCD module and displays WDT on the first line and Running on the second 3 The sample then starts the WDT ADC
10. 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 Electromagnetic 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 equip ment 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 is 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 potent
11. tutorial code calls the FlashLED function which creates a delay to toggle the LEDs repeatedly and waits in a loop until either a switch is pressed or the LEDs flash 200 times 4 The tutorial then calls the TimerADC function which starts an ADC channel configured to run continuously It also starts a periodic timer channel 5 When the timer channel s period elapses the user LEDs are toggled once The A D result is read then used to update the timer s period 6 After calling TimerADC and setting up the timer amp ADC interrupts the tutorial calls the Statics Test function 7 The Statics Test function displays the string STATIC on the second line of the debug LCD and replaces it letter by letter with the constant string TESTTEST Once replacement is complete the LCD reverts back to its original display The tutorial then waits in an infinite while loop The user LEDs toggling continues to run due to the periodic timer The user may vary the period by varying the ADC s potentiometer shaft R20UT0746EG 0100 Rev 1 00 RENESAS Page 12 of 27 Jun 21 2011 RL78G13 4 Tutorial Sample 4 2 Application 4 2 1 Description The application sample is intended as a starting platform for the user to write his her own code The sample in cludes all the necessary initialisation code and configuration settings from previous samples The main function contains no sample code and performs no additional functionality R20UT0746EG 0100 Rev 1 00
12. 13 6 Additional Information 6 Additional Information Technical Support For details on how to use CubeSuite refer to Help gt Tutorial from the menu bar within the CubeSuite For information about the RL78G13 series microcontrollers refer to the RL78G13 Group hardware manual For information about the RL78G13 assembly language refer to the RL78 Series Software Manual Online technical support and information is available at http www renesas com rskrl78g13 Technical Contact Details csc renesas com 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 com panies 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 Lim ited 2011 Renesas Electronics Europe Limited All rights reserved 2011 Renesas Electronics Corporation All rights reserved 2011 Renesas Solutions Corp All rights reserved R20UT0746EG 0100 Rev 1 00 RENESAS Page 23 of 27 Jun 21 2011 REVISION HISTORY RSKRL78G13 Tutorial Manual Date Description Summary 1 00 Jun 21 2011 First Edition issued Renesas Starter Kit Software Help Manual Publi
13. AS Page 13 of 27 Jun 21 2011 RENES RL78G13 5 Peripheral Samples 5 Peripheral Samples The sample code in this section provides examples of initialisation and usage of some of the MCU s peripheral modules The sample code also provides examples of how to debug MCU peripherals 5 1 ADC OneShot 5 1 1 Description This sample code demonstrates usage of the on chip 10 bit and 8 bit analogue to digital converter ADC in one shot mode The sample configures the ADC to read from the potentiometer fitted to the RSK RV1 when user switch SW3 is pressed Note The potentiometer is fitted to offer an easy method of supplying a variable analogue input to the microcontroller It does not necessarily reflect the accuracy of the controllers ADC Refer to the device hardware manual for further details 5 1 2 Operation 1 All peripherals and modules are configured prior to the program calling the main function The A D channel connected to the potentiometer is initially configured for 10 bit precision operations 2 The sample first initialises the debug LCD and displays instructions on the screen 3 The sample then enables the external interrupts connected to the user switches 4 The sample then waits in an infinite while loop and the rest of the sample s functionality is completed through interrupts 5 When switch SW1 is pressed the corresponding external interrupt handler is called This starts an A D con version and wai
14. E T D me 0 lt V I i 6 LENESAS RL78 G13 Renesas Starter Kit Software Help Manual CubeSuite RENESAS MCU RL Family G1X 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 Re nesas 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 Jun 2011 10 11 12 Notice All information included in this document is current as of the date this document is issued Such information however is sub ject to change without any prior notice Before purchasing or using any Renesas Electronics products listed herein please con firm the latest product information with a Renesas Electronics sales office Also please pay regular and careful attention to ad ditional and different information to be disclosed by Renesas Electronics such as that disclosed through our website 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 implie
15. RENESAS Page 21 of 27 Jun 21 2011 RL78G13 5 Peripheral Samples open ther cg userdefine h file and uncomment the following line define USE LCD 5 13 2 Operation l Remove R22 and connect an ammeter on J6 Set the ammeter for current measurement All peripherals and modules are configured prior to the program calling the main function The sample initialises the LCD module displays Snooze on the first line and PressSW1 on the second line if the define USE LCD is uncommented SWI and SW2 interrupts are enabled before the sample then enters an infinite while loop Within the loop pressing SW1 will generates an interrupt which in turn starts an A D conversion with the CPU operating in normal mode Adjust the potentiometer and press SW1 to carry out another conversion Note the current consumption Press SW2 to execute the STOP instruction and stop CPU operations The main clock the internal high speed oscillator is turned off during the stop mode Note the current consumption this will be significantly less than the current noted in Step 5 Press SW3 to start the interval timer The interval timer s period end interrupt causes the CPU to exit the stop mode and trigger an A D conversion without operating the CPU snooze mode The result is displayed on the LCD if enabled The ADC disables the snooze mode function once the CPU is woken up R20UT0746EG 0100 Rev 1 00 RENESAS Page 22 of 27 Jun 21 2011 RSKRL78G
16. RSK hardware Tutorial Provides a guide to setting up RSKRL78G13 Tutorial Manual R20UT0460EG RSK environment running sample code and debugging programs Quick Start Guide Provides simple instructions to RSKRL78G13 Quick Start Guide R20UT0461EG setup the RSK and run the first sample on a single A4 sheet Software Manual Describes the functionality of RSKRL78G13 Software Help R20UTO746EG the sample code Manual Schematics Full detail circuit schematics of RSKRL78G13 Schematics R20UT0458EG the RSK Hardware Manual Provides technical details of the RSKRL78G13 Hardware Manual RO1UH0146EJ RL78G13 microcontroller 2 List of Abbreviations and Acronyms Abbreviation Full Form Analogue to Digital Converter DMAC Direct Memory Access Controller IIC Inter Integrated Circuit Liquid Crystal Display Light Emitting Diode Local Interconnect Network Low Voltage Detection Microcontroller Unit Personal Computer Renesas Starter Kit Real Time Clock Watchdog Timer Table of Contents sOVOVIGN Sk A kk e ak o o eT A o 8 1 1 PUDO rr pr nr on a a o pa o Om p eens On mO mO pn on ay a oa Ni 8 FARA NAVE UNC EL A psec eee pra TE T MR TENTIS 9 3I RSK Sample Code Concepts ses KA EG EG Se Ate avec pate AIS ER 10 3 1 Sample Code Structure s c 2ccie se a o 10 32 Listot Sample Code sss nk ea o points 11 A I NEK KO TO ASINO 12 4 1 IIo E1 js 5
17. RSKRL78G13 as the slave uncom ment the following line found in source file r_cg_typedefine h define SLAVE_RL78G13 Note This sample code requires an external 5V regulated power supply Make the following connections between the RSKRL78G13 and the slave device SDAAO JAI pin 25 lt gt Device SDA SCLAO JA1 pin 26 lt gt Device SDA CON_5V JA1 pin25 lt gt Device Vcc Ov JA1 pin 25 lt gt Device Vss Note Use a 4 7KQ pull up resistor on the data and clock line 5 7 2 Operation 1 Connect and turn on the 5V regulated power supply 2 All peripherals and modules are configured prior to the program calling the main function 3 The sample initialises the LCD module and displays IIC Mstr on the first line R20UT0746EG 0100 Rev 1 00 a2 AS Page 17 of 27 Jun 21 2011 ENES RL78G13 5 Peripheral Samples 4 The sample then enables user switch interrupts before calling the Master EEPROM function 5 Inside the Master EEPROM function the second buffer array location is set to 0x30 which represents the ASCII character 0 6 The sample enters and infinite while loop with the program never returning to the main function Data transfer is handled using interrupts with transmission or reception selected by SW1 and SW3 switch presses respec tively A write operation should always precede a read operation to verify data transferred to the slave device If a read operation is done before a write data is read fr
18. Too e mp Tm p OTT TTT cca te cet e cet aa 12 4 1 1 Descaptlon su Seid mo mp ee ee o Re A e E e ENVI eR de 12 4 1 2 Operations tl stat teat easel is ite e e a e Maat o el cao de ch o soo 12 42 Applicatlofi is sss nein Ap oo eva ee eA aa eee AA ete ee 13 4 2 1 Description ri adoboj pi poro ees ee ae ee A aden eee Ledo 13 Ss Peripheral Samples TTT TTTTTTTITTTT ltd 14 Sel ADC OnNeShob NN 14 5 1 1 IDescel plion 2 ne ok te es boa da o eds a a od lan Sc ara has ahs na Bede 14 5 1 2 O xar mo e No ise A O 14 D2 SAD CARED EAU sss O RE 14 5 2 1 DGS CHIP lk oer TEF EE Tr ETTTET ET TTT TTTTTTTTTTTTTTT TT 14 5 2 2 Operation O 15 DS DI E rene E rr rep rr rr rep rr rr re p o rm ro p Op Po Or 15 5 3 1 IDGSChiptiOniss at stus sman E o lusa GR ui em i oth cet all E 15 5 3 2 Operation jess cas EN IGS NEN ADS I EA 15 STA ASyN Defalis e oe A l TAN sk A a e ps a an kes ko ES A di a kota 16 5 4 1 Descriptio 4 45 so he nap HR ko HR ng ee ie Reseda The et ke ok Re er 16 5 4 2 Opetatlon ss I EN NU EO tee tele ANelo 16 5 5 o O E 16 5 5 1 DESCAPUON sss kem ae dare el o 16 5 5 2 Operationen enin i o T i A I ENG INA SONA N E MAJ 16 se LVD ron sosem ku ETA SAAE T E e EI A OSA A lem eae esses 17 5 6 1 Description sss SN SL EE eee GR OR TR en On EA 17 5 6 2 Operations vince test ro etn olen Sua ts teste o oat oats Cathe Baad No IS o A nka hte 17 5 7 IE ES ro si coeds e 3 MJ oo oan ven tore Mo MH J H UN
19. ained 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 Disclaimer By using this Renesas Starter Kit RSK the user accepts the following terms The RSK is not guaranteed to be error free and the entire risk as to the results and performance of the RSK is as sumed by the User The RSK is provided by Renesas on an as is basis without warranty of any kind whether ex press or implied including but not limited to the implied warranties of satisfactory quality fitness for a particular pur pose 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
20. alls the Slave EEPROM function to specify the start addresses of data to be sent to and re ceived from the master device The sample returns to the main function with data transfers handled at interrupt level 4 Data received from the master device is stored in the 8 byte buffer array Master Data The same data is also sent to the master when a slave read is requested by the master Ne 5 9 Timer 5 9 1 Description This sample configures the timer array unit TAU channels to run one of four applications A total of four TAU channels have been used in the sample The four TAU channels used are channel 0 channel 1 channel 3 and chan nel 5 The implemented applications are Square wave output Capture Event Count and PWM pulse width modu lation The project is configured to run the PWM application by default To change the application change the fol lowing pre processor directive definition with a value corresponding to desired application definition number define Current TMR APP l This can be found in the file r_cg_typedefine h 5 9 2 Operation 1 Al peripherals and modules are configured prior to the program calling the main function The sample initialises the LCD module 3 Depending on the selected application the user will observe one of the following 4 When PWM is selected connect an oscilloscope to pin 9 of JAS 5 For PWM output the sample displays Tr PWM on the first line of the debug LCD enables s
21. and displays Async on the first line and Serial on the second The sample enables SAUO s channel 0 for RS 232 operations and starts the interval timer The rest of the program is handled at interrupt level The interval timer generates a periodic interrupt every 100ms handled by the corresponding interrupt handler The interrupt handler checks the character entered in the terminal emulator and transmits an incrementing ASCII number loops back to 0 after 9 to the terminal display if the character was not z LEDO is turned on to indicate transmission is in progress If the character was z transmission is stopped and LEDO is turned off ox pu e ULO 5 5 Sync Serial 5 5 1 Description This sample code demonstrates usage of serial array unit SAU configured in synchronous mode The SAU mod ule is setup to perform loop back communication between two SAU channels using a 3 wire interface Make the following connections TxDO JA2 pin6 gt RxDI JA6 pin 7 RxDO JA2 pin8 lt TxDI JAG pin 8 SCK00 JA2 pin 10 lt gt SCKIO JA6 pin 10 5 5 2 Operation 1 All peripherals and modules are configured prior to the program calling the main function 2 The sample initialises the LCD module and displays Sync on the first line and Serial on the second 3 The sample then calls the Sync_Transfer function which clears the reserved SAU data buffers SAU chan nelsCSI00 and CSI10 are enabled and op
22. cation Date Rev 1 00 Jun 21 2011 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 2880 Scott Boulevard Santa Clara CA 95050 2554 U S A Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 101 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 65030 Fax 49 211 6503 1327 Renesas Electronics China Co Ltd 7th Floor Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100083 P R China Tel 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd Unit 204 205 AZIA Center No 1233 Lujiazui Ring Rd Pudong District Shanghai 200120 China Tel 86 21 5877 1818 Fax 86 21 6887 7858 7898 Renesas Electronics Hong Kong Limited Unit 1601 1613 16 F Tower 2 Grand Century Place 193 Prince Edward Road West Mongkok Kowloon Hong Kong Tel 852 2886 9318 Fax 852 2886 9022 9044 Renesas Electronics Taiwan Co Ltd 7F No 363 Fu Shing North Road Taipei Taiwan Tel 886 2 8175 9600
23. d or otherwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part 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 When exporting the 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 You should not use Renesas Electron ics products or the technology described in this document for any purpose relating to military applications or use by the mili tary including but not limited to the development of weapons of mass destruction Renesas Electronics products and technol ogy 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 Renesas Electronics has used reasonable care in preparing the information
24. ection before either starting R20UT0746EG 0100 Rev 1 00 a2 AS Page 19 of 27 Jun 21 2011 ENES RL78G13 5 Peripheral Samples or stopping channel 5 s counting If the edge detection is falling edge detection the interrupt count variable gTimerTick is cleared and the edge detection is changed to rising edge detection Channel 5 s counting is then started prior to the interrupt handler exiting and returning to the main function The count continues for the du ration of SW1 being held down TAU Channel 5 s interrupt handler is called several times incrementing gTimer Tick by a value of 1 within this duration As soon as SW1 is released the corresponding interrupt handler is called to stop TAU channel 5 s counting check if the counting is less than 10000 If less the hex count value is converted to a binary coded decimal BCD string and displayed on the second line of the debug LCD in milliseconds If the value is exceeds 10000 then the string gt 10s is displayed instead to indicate that the duration exceeds 10 seconds The signal detection is changed back to falling edge detection before ex iting the interrupt handler and returning to the main function until the next time SW1 is pressed For Event Count the sample displays Tr Event on the first line of the debug LCD and Count on the sec ond Count variable gEventCount is cleared before TAU channel 3 s count is started The sample then enters an infinite while loop
25. ed using the received data before being compared to the received checksum If the checksums match the received data is converted to a string and displayed on the debug LCD The process is repeated infinitely until program execution is stopped 8 In slave mode the sample periodically awaits the LIN header transmitted by the master The sample uses inter rupts to detect the LIN header data When the received slave address matches 0x10 function LIN Slave Transmit is called This function start s an A D conversion waits for the conversion to complete stores the integer result converts it to a specially arranged string buffer array then transmits the data The func tion exits and returns to main The received slave address storage is cleared before the next header is received The process is repeated infinitely until program execution is stopped R20UTO746EG 0100 Rev 1 00 a2 AS Page 15 of 27 Jun 21 2011 ENES RL78G13 5 Peripheral Samples 5 4 Async Serial 5 4 1 Description This sample code demonstrates usage of serial array unit SAU configured in asynchronous mode The SAU module is setup to communicate to a PC running a terminal emulator program via an RS 232 cable 5 4 2 Operation 1 Before the sample begins the user should connect the RSK to a PC via an RS 232 cable and start the terminal program All peripherals and modules are configured prior to the program calling the main function The sample initialises the LCD module
26. erational with data transfer between the two channels Channel CSI00 is configured as the master and outputs the clocking signal to channel CSI10 which is configured as the slave Both channel s data transmission and reception are handled using interrupts A delay is created using a timer channel to allow the transfer to complete before the user can check the outcome A Failure message will be displayed on the second line of the debug LCD when an error occurs during data transfer otherwise data transfer between the two channels are compared at the end of transfer and Success is dis played on the second line of the debug LCD If any of the data did not match the message Failure is dis played instead 4 The sample then enters an infinite while loop R20UT0746EG 0100 Rev 1 00 RENESAS Page 16 of 27 Jun 21 2011 RL78G13 5 Peripheral Samples 5 6 LVD 5 6 1 Description In this sample the LVD Low Voltage Detection circuit is configured to generate an interrupt when the power sup ply equals or falls below the detection level The detection level is approximately 4 06 Volts 5 6 2 Operation 1 All peripherals and modules are configured prior to the program calling the main function 2 The sample initialises the LCD module and displays LVD on the first line 3 The sample calls enable LVD operations as well as start a periodic timer before entering an infinite while loop 4 The rest of the sample is handled at
27. he sample code provided and its interaction with CubeSuite s Code Generator Code Generator is a tool within CubeSuite used for generating code for configuring the on board peripherals and modules depending on user setting selections Code Generator can also generates code for interrupt handling as well as peripheral start and stop functions This manual is not intended to be a tutorial on using Code Generator or how Code Generator works it simply aims to explain to the reader how the Code Generator was used to develop the sample codes R20UT0746EG 0100Rev 1 00 TENESAS Page 8 of 27 Jun 21 2011 RL78G13 2 Introduction 2 Introduction This document explains by text the functionality of the sample code and the steps required to observe the correct operation of each sample R20UT0746EG 0100 Rev 1 00 LEN ESAS Page 9 of 27 Jun 21 2011 RL78G13 3 RSK Sample Concept 3 RSK Sample Code Concept 3 1 Sample Code Structure The basic structure of all RSK sample code is shown in Figure 2 1 below The first two functions hdwinit and systeminit configure the MCU before the main program code executes Reset hdwinit R_Systeminit Hardware setup consists of the following functions R_CGC_Get_ResetSource R_PORT_Create R_CGC_Create Final State Figure 2 1 Sample Code Structure All sample code projects are configured with the main function as the entry point after a succes
28. ially 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 regula tory standards for an end product How to Use This Manual 1 Purpose and Target Readers This manual is designed to provide the user with an understanding of the sample projects The manual comprises of an overview of each sample and what is required by the user to successfully execute the samples 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 RL78G13 Group Make sure to refer to the latest versions of these docu ments 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 RSKRL78G13 User s Manual R20UT0459EG of the
29. 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 in curred by you resulting from errors in or omissions from the information included herein Renesas Electronics products are classified according to the following three quality grades Standard High Quality and Specific The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below You must check the quality grade of each Renesas Electronics product before using it in a particular applica tion You may not use any Renesas Electronics product for any application categorized as Specific without the prior written consent of Renesas Electronics Further you may not use any Renesas Electronics product for any application for which it is not intended without the prior written consent of Renesas Electronics 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 an applica tion categorized as Specific or for which the product is not intended where you have failed to obtain the prior written con sent of Renesas Electronics The quality grade of each Renesas Electronics product is Standard unless otherwise expressly specified in a Renesas Electronics data sheets or data books etc
30. ith other signals though they are not used The 1Hz can be observed on pin 16 of J2 5 12 2 Operation 1 All peripherals and modules are configured prior to the program calling the main function The sample initialises the LCD module and displays RTC on the first line and 00 00 00 on the second 3 The sample then enables the output of the RTC s 1Hz signal before enabling the RTC module and entering an infinite while loop 4 The rest of the sample is handled using interrupts 5 Each IHz count corresponding to 1 second generates an interrupt The interrupt handler executes the callback function RTC_ConstPeriodInterruptCallback which reads the RTC registers converts them to ASCII equivalent values then displayed on the debug LCD 5 13 Snooze 5 13 1 Description This sample demonstrates low power standby mode by placing the CPU in stop mode to reduce current consump tion The interval timer s interrupt is used to wake the CPU from stop mode before triggering an A D conversion independent of the CPU snooze All the contents of registers flags and data memory just before the stop mode is set are held The I O port output latches and output buffer statuses are also held The snooze mode can only be specified when the internal high speed oscillation clock is selected as the main clock By default the debug LCD is not used The LCD can be used to view the A D conversion results To use the LCD R20UT0746EG 0100 Rev 1 00
31. layed on the debug LCD to 5 3 LIN 5 3 1 Description This sample code demonstrates usage of Local Interconnect Network LIN configured in master or slave mode depending on user selection The mode can be selected by including or excluding the pre processor instruction in define MASTER LIN Note The slave mode requires resistor link changes Please refer to the Description txt file for the resistor refer ences This sample code requires an external 5V regulated power supply 5 3 2 Operation 1 Using a three way LIN connector connect the RSKRL78G13 to the slave master device 2 Connect and turn on the 5V regulated power supply 3 All peripherals and modules are configured prior to the program calling the main function 4 The sample initialises the LCD module and displays either LIN Mstr or LIN Slav on the first line of the debug LCD depending on the selected operation mode 5 The sample then enables the external interrupt INTPO 6 The off chip LIN transceiver is enabled and user LEDI is turned off 7 In master mode the sample periodically transmits the LIN header until data reception from the slave is de tected Detection is handled using interrupts The corresponding interrupt handler stores the received data to a specified address range On detection of slave data reception the function LIN Master Receive is also called stopping the timer operation and disabling serial operations A checksum is calculat
32. of the SCI module in synchronous mode Timer Demonstrates usage of the Timer s multifunction capabilities in 4 different modes Tutorial Demonstrates basic usage of the debugger and RSK hardware Watchdog Demonstrates usage of the watchdog timer by causing a WDT overflow interrupt R20UT0746EG 0100 Rev 1 00 Jun 21 2011 Table 2 1 Sample Code List TENESAS Page 11 of 27 RL78G13 4 Tutorial Sample 4 Tutorial Sample 4 1 Tutorial The sample code in this section is basic tutorial code used to demonstrate basic usage of the RSK and help the user to begin writing his her own basic sample code 4 1 1 Description The tutorial sample code demonstrates basic usage of the debugger and RSK hardware and is common to all RSKs This sample is supplied programmed onto the MCU and executes out of the box when power is applied The sample calls three main functions to demonstrate port pin control interrupt usage and C variable initialisation These functions are shown in Figure 3 1 below main FlashLED Y Static_Test Y While 1 t Figure 4 1 Tutorial Sample Flow 4 1 2 Operation 1 Al peripherals and modules are configured prior to the program calling the main function 2 The tutorial code initialises the LCD module and displays Renesas on the first line of the LCD and the name of the MCU on the second line 3 The
33. om the slave device but not displayed on the second line of the LCD Instead the message IIC Push is displayed on the first line and SW1 SW3 displayed on the second line informing the user to press SW1 then SW3 7 Pressing switch SW2 allows the user to display the last data sent to the slave device 8 After a write and read operations have taken place data sent and received are compared If data mismatch oc curs messages IIC Mstr W R Diff are displayed on the first and second LCD lines respectively 5 8 IIC Slave 5 8 1 Description This sample demonstrates usage of the IIC unit in slave mode by simulating a simple 8 byte EEPROM memory device 5 8 2 IIC Slave Commands 1 Write Operation To write to the simulated EEPROM the master should send a start condition followed by the EEPROM device address default address 0x10 and wait for an ACK acknowledgement signal from the slave The master should proceed by sending 8 bytes of data including the 8bit EEPROM memory address not used and then wait for an ACK response from the slave The memory address byte is disregarded since the slave saves the received bytes starting at the same address for each 8 byte transfer The master should wait for an ACK response after each data byte The slave is configured and expecis to receive 8 bytes of data Once the final byte has been sent the master should send a stop signal to end the transaction
34. sful build and pro gramming of the board The program code is automatically executed after programming the device and stopped at the first instruction inside the main function As a result the user will not be able to step through the hardware ini tialisation code CubeSuite permits the user to change the program entry point by specifying another function other than main Please refer to the Tutorial manual for more information on this The sample code descriptions in this manual focus on the program execution within the main function R20UT0746EG 0100 Rev 1 00 RENESAS Page 10 of 27 Jun 21 2011 RL78G13 3 2 3 RSK Sample Concept List of Sample Code Table 2 2 below lists the sample code supplied with the RSKRL78G13T and describes their function Sample Code Description ADC_Oneshot Demonstrates usage of the 10bit and 8bit ADC module in one shot mode ADC_Repeat Demonstrates usage of the 10bit and 8bit ADC module in repeat mode Application Blank project used for development Async_Serial Demonstrates usage of the SCI module in asynchronous mode DMAC Demonstrates usage of the DMAC module by performing interrupt requested transfers IIC Demonstrates usage of the IIC module in master or slave mode LIN Demonstrates usage of the LIN module in master or slave mode LVD Demonstrates usage of the LVD circuit to generate interrupts on low voltage detections Sync_Serial Demonstrates usage
35. ts for conversion to complete After completion the interrupt handler checks the precision mode status The result is saved according to the precision mode before converting the integer A D value to a specially arranged string in a buffer array The string is then displayed on the debug LCD before the interrupt handler exits and program execution returns to the main function 6 Pressing switch SW2 calls the corresponding external interrupt handler which changes the precision mode to 8 bits and sets the precision mode status to 2 to indicate selection of 8 bits precision The interrupt handler exits and returns to the main function 7 Pressing switch SW3 calls the corresponding interrupt handler which changes the precision mode to 10 bits and sets the precision mode status to 3 to indicate that the current mode is 10 bits 5 2 ADC_Repeat 5 2 1 Description This sample code demonstrates usage of the on chip 10 bit and 8 bit analogue to digital converter ADC in repeat mode The sample configures the ADC to repeatedly take readings of the potentiometer voltage RV1 The sample then updates the conversion value displayed on the LCD through periodic interrupts from the timer module Note The potentiometer is fitted to offer an easy method of supplying a variable analogue input to the microcontroller It does not necessarily reflect the accuracy of the controllers ADC Refer the device hardware manual for further de tails
36. witches SW1 and SW2 s external interrupts before starting TAU channel 0 which is configured to output a PWM waveform The sample then enters the main while loop and the rest of the functionality is performed at interrupt level TAU channel 0 s period is set to 1 ms with the duty varying between 0 90 The waveform is output on channel 0 s output pin TOO observed on pin 9 of application header JAS Pressing switch SW1 will freeze the duty cycle from varying and display the percentage on line two of the debug LCD subsequently switch SW2 presses resumes the variations and clears the debug LCD s line 2 6 When Square wave output is selected connect an oscilloscope to pin 20 of JA2 7 For Square wave output the sample displays Tr SqOut on the first line of the debug LCD and JA2 20 on the second A 1KHz square wave is output on channel 5 s output pin TOOS observed on pin 20 of the applica tion header JA2 8 For Interval measurement the sample displays Tr Intvl on the first line of the debug LCD and Push SW1 on the second The external interrupt pin connected to switch SW1 is enabled before the sample enters an infi nite while loop The rest of the sample is handled using interrupts TAU s channel 5 is configured to periodi cally generate interrupts at 1ms intervals Pressing down on SW1 generates an interrupt handled by the corre sponding interrupt handler The interrupt handler firstly verifies the signal edge det
37. with the rest of the application handled by interrupts TAU channel 3 is configured to be clocked by an external clock signal on its input signal pin TI03 This pin is multiplexed with the output signal TOO3 as well as the external event interrupt signal INTP4 connected to SW3 The external even interrupt is disabled and the falling edge signals of SW3 clocks TAU channel 3 An interrupt request is generated on each falling edge signal and handled by the corresponding interrupt handler The interrupt handler checks if the count of detected events is less than 99 and increments the count if this is true otherwise the count is set to one The hex count value is converted to a string and displayed on the debug LCD s second line 5 10 DMAC 5 10 1 Description This to an sample demonstrates usage of the DMAC Direct Memory Access Controller by performing a DMA transfer incrementing location in an array when switch SW1 is pressed Open the Memory window from the menu bar View gt Memory gt Memory Scroll to address range OxFFA00 OxFFBFF Observe the random data stored within these locations 5 102 Operation l 2 er ovi 5 11 All peripherals and modules are configured prior to the program calling the main function The sample initialises the LCD module and displays DMAC on the first line and Push SW1 on the sec ond All user LEDs are turned on The sample enables switch SW1 interrupts and waits for the user to

Download Pdf Manuals

image

Related Search

Related Contents

Pratiques de communication : figures de la médiation      Manual do Produto  Maquinas limpiaplayas Windland manual de instrucciones  TERMOSIGILLATRICE ELETTRONICA - Tecno-Gaz  PC-T1 電子マニュアル    Intellinet PCI 10/100 LP  Box 459 - Febrero-Marzh 1979  

Copyright © All rights reserved.
Failed to retrieve file