Home

Renesas Starter Kit for RX210 Software Manual

image

Contents

1. Init LCD p gt lt lt Displays the sample name instructions on the Display LCD debug LCD Init AnalogCompare Configures analog compare unit to call the callback function CB Comparator I AnalogCompare gt gt l lt lt Comparator x gt ref interrupt gt gt P lt lt Infinite while loop gt gt lt lt Function sets LEDs and LCD to indicate that analog input is greater than the CB_Comparator_ reference voltage gt gt AnalogCompare 1 z 7 l 5 lt lt Comparator Es ref interrupt gt gt gt lt lt Function sets LEDs and LCD to indicate that analog input is lower than the CB_Comparator_ reference voltage gt gt AnalogCompare Lag l LOOP Figure 4 15 Analog_Compare Sequence Diagram R20UT0305EG0200 Rev 2 00 TENESAS Page 40 of 52 Jul 09 2012 RSKRX210 4 15 3 RPDL Integration 4 Peripheral Samples Function RPDL Function Init_AnalogCompare R CPA Create CB Comparator AnalogCompare R_CPA_GetStatus R IO PORT Write R CMT CreateOneShot R20UT0305EG0200 Rev 2 00 Jul 09 2012 Table 4 15 Analog Compare Sample RPDL Integration RENESAS Page 41 of 52 RSKRX210 4 Peripheral Samples 4 16 Data Operation Circuit DOC This sample code demonstrates usage of the data operation circuit DOC by comparing a user input from a PC te
2. Figure 4 9 PWM Sequence Diagram R20UT0305EG0200 Rev 2 00 TENESAS Page 28 of 52 Jul 09 2012 RSKRX210 4 9 3 RPDL Integration 4 Peripheral Samples Function RPDL Function Init PWM R TMR Set R TMR CreatePeriodic CB Timer PWM R_TMR_ControlPeriodic Table 4 9 PWM Sample RPDL Integration R20UT0305EG0200 Rev 2 00 RENESAS Jul 09 2012 Page 29 of 52 RSKRX210 4 Peripheral Samples 4 10 WDT This sample code demonstrates the usage of the watchdog timer functionality by resetting the WDT count regularly at a rate controlled by the potentiometer to prevent its period from timing out When the WDT s period is reached the LEDs stop flashing and the program halts in an infinite while loop 4 10 1 Operation Before starting this sample ensure that the potentiometer shaft is turned anti clockwise fully 1 The sample initialises the debug LCD and displays the sample name instructions on the screen 2 The Init WDT function configures the watchdog timer unit the ADC unit and a timer unit The ADC unit is configured to operate in continuous mode and the timer is configured to generate an interval interrupt that executes the callback function CB Timer WDT 3 The sample then enters an infinite while loop The while loop is interrupted by the CB Timer WDT callback function This function resets the WDT count toggles the LEDs and fetches the ADC result This result is used to set the new timer
3. R CMT Create R ADC 12 Control CB Timer ADC12Repeat R ADC 12 Read Table 4 1 ADC Repeat Sample RPDL Integration R20UT0305EG0200 Rev 2 00 RENESAS Page 15 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 2 Async_Serial This sample code demonstrates an asynchronous serial communication using the on chip serial interface module 4 2 1 Operation Before starting the sample the user should connect the RSK to a PC via an RS 232 cable and start the terminal program refer to the instructions in the sample code comments Q The sample first initialises the debug LCD and displays the sample name instructions 2 The Init_Async function is called which initialises the SCI unit to operate in asynchronous mode with the settings detailed in the sample code comments The function also configures a SCI receive interrupt which generates an interrupt every time data is received in the SCI unit Finally a timer unit is configured which generates interval interrupts used to call the CB Timer Async callback function 3 The sample then enters an infinite while loop The callback function CB Timer Async is called with every timer interval interrupt The function checks the status of the gSCI Flag and continues to transmit an incrementing number over SCI with the flag is true The function exits without transmitting if the flag is false Whilst transmitting LEDO will remain on and LEDI off a The callback fu
4. e 7 LOOP l l l l l l l Figure 4 18 Low Power Sequence Diagram R20UT0305EG0200 Rev 2 00 LENESAS Page 46 of 52 Jul 09 2012 RSKRX210 4 18 3 RPDL Integration 4 Peripheral Samples Function RPDL Function Init_LowPower R_LPC_Create R_CGC_Control R_DMAC_Destroy IdleFunction_LowPower R_IO_PORT_Modify R_CMT_CreateOneShot R_CGC_Set R_CGC_Control R_LPC_Create R_IO_PORT_Write R_LPC_Control R20UT0305EG0200 Rev 2 00 Jul 09 2012 Table 4 18 Low Power Sample RPDL Integration RENESAS Page 47 of 52 RSKRX210 5 Additional Information 5 Additional Information Technical Support For details on how to use High performance Embedded Workshop HEW refer to the HEW manual available on the CD or from the web site For information about the RX210 series microcontrollers refer to the RX210 Group hardware manual For information about the RX210 assembly language refer to the RX Series Software Manual Online technical support and information is available at http www renesas com rskrx210 Technical Contact Details America techsupport america renesas com Europe software support eu 1m renesas com Japan csc Crenesas 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
5. D D 0 A y O N LENESAS RX210 Group Renesas Starter Kit Software Manual RENESAS MCU RX Family RX200 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 2 00 Jul 2012 Notice l All information included in this document is current as of the date this document is issued Such information however is subject to change without any prior notice Before purchasing or using any Renesas Electronics products listed herein please confirm the latest product information with a Renesas Electronics sales office Also please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website 2 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
6. Fax 1 408 588 6130 Renesas Electronics Canada Limited 1101 Nicholson Road Newmarket Ontario L3Y 9C3 Canada Tel 1 905 898 5441 Fax 1 905 898 3220 Renesas Electronics Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel 44 1628 651 700 Fax 44 1628 651 804 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 13F No 363 Fu Shing North Road Taipei 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 906 Block B Menara Amcorp Amcorp Trade Centre No 18 Jin Persiaran Barat 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel 60 3
7. O Display_LCD lt lt Instructions are displayed l on the debug LCD gt gt lt lt Configures the DTC unit for a normal transfer gt gt lt lt Switch interrupt gt gt lt lt Infinite while loop gt gt lt lt Switch callback function triggers AD conversion which then triggers a DTC CB_Switch_ transfer gt gt DTC while 1 Figure 4 5 DTC Sequence Diagram R20UT0305EG0200 Rev 2 00 TENESAS Page 21 of 52 Jul 09 2012 RSKRX210 4 5 3 RPDL Integration 4 Peripheral Samples Function RPDL Function Init DTC CB Switch DTC R DTC Set R DTC Create R DTC Control R ADC 12 Set R ADC 12 CreateUnit R ADC 12 CreateChannel R INTC Write R INTO Modify R DTC GetStatus R DTC Control R INTC Write R ADC 12 Control R IO PORT Modify R20UT0305EG0200 Rev 2 00 Jul 09 2012 Table 4 5 DTC Sample RPDL Integration RENESAS Page 22 of 52 RSKRX210 4 Peripheral Samples 4 6 LVD 4 6 1 Description In this sample the LVD Low Voltage Detection circuit s is configured to generate an interrupt when the power supply equals or falls below the detection level 4 6 2 PO Operation Before starting this sample follow the instructions in main source file to ensure the RSK is configured correctly Connect a 5V variable power supply to the power socket and set the ini
8. The newest versions of the documents listed may be obtained from the Renesas Electronics Web site Document Type Description Document Title Document No User s Manual Describes the technical details of the RSK hardware RSK RX210 User R20UT0302EG Manual Software Manual Describes the functionality of the sample code and RSK RX210 R20UT0305EG its interaction with the Renesas Peripheral Driver Software Manual Library RPDL Tutorial Provides a guide to setting up RSK environment RSK RX210 R20UT0303EG running sample code and debugging programs Tutorial Manual Quick Start Guide Provides simple instructions to setup the RSK and RSK RX210 Quick R20UT0304EG run the first sample on a single A4 sheet Start Guide Schematics Full detail circuit schematics of the RSK RSK RX210 R20UT0301EG Schematics Hardware Manual Provides technical details of the RX210 RX210 Hardware RO1UH0037EJ microcontroller Manual 2 List of Abbreviations and Acronyms Abbreviation Full Form Central Processing Unit Data Operation Circuit Event Link Controller Microcontroller Unit Serial Communication Interface Serial Peripheral Interface Pulse Width Modulation Direct Memory Access Controller Watchdog Timer Real Time Clock Data Transfer Controller PhillipsTM Inter Integrated Circuit Connection Bus Cyclic Redundancy Check Table of Contents IO e e E A e TETTE TTT TE ETTTETTTETIT
9. 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 2012 Renesas Electronics Corporation All rights reserved Colophon 1 3 RX210 Group TENESAS Renesas Electronics Corporation R20UT0305EG0200
10. CRC Read Table 4 3 CRC Sample RPDL Integration R20UTO305EGO200 Rev 2 00 RENESAS Page 19 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 4 DMAC This sample code configures the DMAC unit to perform a data transfer to the global variable gDMA_DataBuff 4 4 1 Operation QD The sample initialises the debug LCD and displays instructions on the screen 2 The function Init DMAC is called to configure a DMAC channel for consecutive data transfers The transfer mode is set to automatically increment the data destination address after each transfer A callback function CB_DMACTransferEnd_DMAC is configured to be called on completion of all transfers The DMAC is enabled and the transfer operation is started before the sample enters an infinite while loop 6 On completion of all data transfers the CB_DMACTransferEnd_DMAC callback function is called and turns on LEDI to indicate the operation has ended 4 4 2 Sequence Diagram l Init LCD p l Displays instructions on l the debug LCD gt gt O l Display LCD l l l l l l l l l l ke l l l l l l T lt lt Configures a DMAC channel Init DMAC T DMAC interrupt gt lt lt Turns on LED1 to indicate completion of data transfers gt gt CB DMACTI f i ransfer End DMAC then starts the transfer Figure 4 4 DMAC Sequence Diagram 4 4 3 RPDL Integration
11. Display LCD debug LCD gt gt l lt lt Initialises the SCI unit to communicate with a PC Init DOC terminal and the DOC unit to perform comparisons to a reference integer SCI Recieve interrupt Infinite while loop O lt lt SCI Receive callback function fetches user input and calls the Comparelnput _DOC function gt gt lt lt Function takes user input and copies it into the DOC input register and performs a comparison then updates the UART terminal indicating if the input matched the reference or not gt gt while 1 CB_SCIRecieve_DOCI lt lt Program returns to while loop gt gt LOOP Figure 4 16 Data Operation Circuit DOC Sequence Diagram R20UT0305EG0200 Rev 2 00 TENESAS Page 42 of 52 Jul 09 2012 RSKRX210 4 16 3 RPDL Integration 4 Peripheral Samples Function RPDL Function Init DOC R DOC Create R SCI Create R SCI Receive R SCI Send R SCI Control CB SCIReceive DOC R SCI Send R DOC Write R DOC Read R SCI GetStatus R SCI Receive Table 4 16 Data Operation Circuit DOC Sample RPDL Integration R20UT0305EG0200 Rev 2 00 Jul 09 2012 RENESAS Page 43 of 52 RSKRX210 4 Peripheral Samples 4 17 Event Link Controller ELC This sample code demonstrates usage of the event link controller ELC The sample
12. Function RPDL Function Init DMAC R DMAC Create R DMAC Control R_INTC_ Modify CB DMACTransferEnd DMAC R DMAC GetStatus R IO PORT Write R DMAC Control Table 4 4 DMAC Sample RPDL Integration R20UTO305EGO200 Rev 2 00 TENESAS Page 20 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 5 DTC This sample demonstrates usage of the DTC unit by performing a DTC transfer of an ADC result to an incrementing location in an array when a switch is pressed 4 5 1 Operation O The sample initialises the debug LCD and displays instructions on the screen 2 The sample calls the function Init DTC which configures the DTC unit and also configures an ADC channel which will trigger a DTC transfer after a successful conversion The DTC transfer is configured to transfer the content of the ADC result register to incrementing locations in the global array gDTC_Destination 3 The sample then enters an infinite while loop with the rest of the sample s functionality completed in interrupts When switch SW3 is pressed the callback function CB_Switch_DTC is called The callback function checks the number of remaining transfers and triggers an AD conversion If there are no more remaining transfers the function clears the contents of the gDTC Destination array and reconfigures the DTC transfer to start from the beginning 4 5 2 Sequence Diagram Init LCD T L l l
13. any patents copyrights or other intellectual property rights of Renesas Electronics or others 3 You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part 4 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 5 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 Electronics products or the technology described in this document for any purpose relating to military applications or use by the military including but not limited to the development of weapons of mass destruction 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 6 Renesas Electronics has used reasonable care in preparing the information included in this document but R
14. ie aden ied teed ee 21 4 5 1 Opera TTT TTT TT TTT TTT TOE A 21 4 5 2 Sequence Dia SEAMS sse cass rr TETTE in TTT TTT TT TJ 21 4 5 3 RPDE Inte Station 3 sisi mp ii ob E and haves notes eke 22 RIM END ints totic A Gace Is 23 4 6 1 DESCHIption 2 spenso te sesgstecy ids aseastee ease bnsdoro boso pe A ove pas Do Ka apena idas 23 4 6 2 A NS 23 4 6 3 AD AAA ON 23 4 6 4 RPDE Inte station cusco is 24 4 7 Pr DAA TITT TETTE TETTTTETTTFETEETETEYTTE EETI GRE 25 4 7 1 Oro rus NON 25 412 SEQUENCE Dia TAM Se enen EA nem a IAM Sr ne 25 4 7 3 RPDE Tonterias 26 4 8 Timer Modem sisi on o I Saa 27 4 8 1 ODETA ONS mu un aes nn aen o aa at a 27 4 8 2 SEQUENCE Dia CLAM tt ia son ene Soe ron sete tienes Pees ondo 27 4 8 3 RPDE Integration ws he ies t o Laa ea ee i a sv ku l i eta 27 AiO PWIM ethics cect ere Ir TTT TE TETTE TTT TTT ETT TTT res Sad A aad teed sade to 28 4 9 1 Operation it 28 4 9 2 Sequence Diarra an 28 4 9 3 REDE Integrati ON aiii 29 I UA A DI E Hoe TTT A A S E T A TTT AEN saree 30 4 10 1 ODEFA ONA sm un na un a a o oe oo 30 4 10 2 SEQUENCE Diu TA ii tte 30 4 10 3 RPDE Integration iis st e nos BERS SR ui roo OO o Ee 31 4 lb A p SA o o al Sa A Ko e ate a ean un e po Io ag tae sank ob 32 4 11 1 LO ola kE E A ieee eae hata oleae 32 4 11 2 Sequence DIapram isso kt esac O 32 4 11 3 RPDE te Station os cisci oss TTT TTT TT E TTETE TTEETE TETTE TETTE E EE TE EEA S 33 BIZ GEI hir coi 34 4 12 1 OJ Nor r hor TT sage seduce TETTE
15. l l l l conversion and configures a switch callback function gt gt 1 Switch press interrupt lt lt Infinite while loop gt gt lt lt Starts an A D conversion reads the result converts the hex value result to a string and displays it on the debug LCD gt gt CB Switch ELC while 1 ADC operation complete selected port pin without the need to interrupt the CPU s operation ELC automatically toggles the pre Program returns to while loop Figure 4 17 Event Link Controller ELC Sequence Diagram R20UT0305EG0200 Rev 2 00 TENESAS Page 44 of 52 Jul 09 2012 RSKRX210 4 17 3 RPDL Integration 4 Peripheral Samples Function RPDL Function Init_ELC R_ADC_12_Set R ELC Create R ELC Control R ADC 12 CreateUnit R ADC 12 CreateChannel R IO PORT Set R IO PORT Write CB Switch ELC R ADC 12 Control R ADC 12 Read Table 4 17 R20UT0305EG0200 Rev 2 00 Jul 09 2012 Event Link Controller ELC Sample RPDL Integration RENESAS Page 45 of 52 RSKRX210 4 Peripheral Samples 4 18 Low_Power The Low Power sample demonstrates the low power functionality of the MCU The MCU toggles between low power CPU active sleep mode CPU inactive and normal full power mode 4 18 1 Operation This sample should be flashed onto the MCU and run without the debugger Before sta
16. mitigate against them it is recommended that the following measures be undertaken The user is advised that mobile phones should not be used within 10m of the product when in use The user is advised to take ESD precautions when handling the equipment The Renesas Starter Kit does not represent an ideal reference design for an end product and does not fulfil the regulatory standards for an end product How to Use This Manual 1 Purpose and Target Readers This manual is designed to provide the user with an understanding of the RSK hardware functionality and electrical characteristics It is intended for users designing sample code on the RSK platform using the many different incorporated peripheral devices The manual comprises of an overview of the capabilities of the RSK product but does not intend to be a guide to embedded programming or hardware design Further details regarding setting up the RSK and development environment can found in the tutorial manual 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 RX210 Group Make sure to refer to the latest versions of these documents
17. set reference voltage 4 15 1 O O Operation This sample may require hardware modifications in order to operate Refer to the sample code instructions for further information before proceeding The sample first initialises the debug LCD and displays the sample name instructions It then calls the function Init_AnalogCompare which configures the comparator unit The unit is configured to execute the callback function CB_Comparator_AnalogCompare function when the input voltage to comparator is higher than the reference voltage The sample then enters an infinite while loop When the input voltage exceeds the reference a comparator interrupt is generated which calls the function CB_Comparator_AnalogCompare This function sets the LCD and user LEDs to indicate that the input voltage is higher than the reference voltage It also reconfigures the comparator interrupt to trigger when the input goes below the reference voltage When the input voltage goes below the reference voltage the comparator generates another interrupt and calls the CB Comparator AnalogCompare The function sets the LCD and user LEDs to indicate that the input is lower than the reference voltage The function also reconfigures the comparator interrupt to trigger when the inputs goes above the reference voltage When the input goes high again the sample repeats steps 3 amp 4 4 15 2 Sequence Diagram Main LCD Potentiometer
18. 00 Rev 2 00 TENESAS Page 10 of 52 Jul 09 2012 RSKRX210 3 Tutorial Samples 3 1 2 3 1 3 Operation 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 The tutorial code calls the Flash_LED function which creates a timer interrupt with callback function CB_TimerLED to toggle the LEDs repeatedly and waits in a loop until either a switch is pressed or the LEDs flash 200 times The tutorial then calls the Timer_ADC function which configures the ADC unit and a timer unit to periodically trigger an ADC conversion The ADC unit is configured to call the function CB_ADConversion after each AD conversion completes The timer is configured to call the function CB_ Timer The callback function CB_ADConversion is triggered by ADC interrupts It fetches the ADC result and uses it to set a new timer period The callback function also toggles the user LEDs After calling Timer_ADC and setting up the timer amp ADC interrupts the tutorial calls the Static_Test function which runs in parallel to the callback functions in step 4 This function displays the string STATIC which is fetched from a static variable and is replaced letter by letter by the string TESTTEST The LCD then reverts to the original display on completion After the Static_Test function completes the MCU waits in an infinite while loop and is periodically interr
19. 10 4 Peripheral Samples 4 23 RPDL Integration Function RPDL Function Init Async R SCI Create R SCI Receive R SCI Send R CMT Create Transmit Async R SCI Send R IO PORT Write CB Timer Async R SCI GetStatus CB SCIReceive Async R IO PORT Write R SCI Receive Table 4 2 Async Serial Sample RPDL Integration R20UTO305EGO200 Rev 2 00 RENESAS Page 17 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 3 CRC 4 3 1 Description This sample demonstrates the CRC unit by echoing typed characters from the SCI terminal with a corresponding checksum 4 3 2 O O O 4 3 3 Operation Before starting this sample the user should connect the RSK to the PC via an RS232 serial cable and run a suitable terminal program see instructions in sample code comments The sample first initialises the debug LCD and displays the sample name instructions The sample then calls the function Init_CRC which configures the CRC unit to produce checksums and the SCI unit for asynchronous operation to and from the PC terminal The sample then enters an infinite while loop and the rest of the sample s functionality is performed in interrupts When the user presses a key in the terminal the SCI interrupt executes the callback function CB SCIReceive CRC This function takes the received character and calls the function Calculate_CRC to generate a checksum The function Calculate_CRC inserts th
20. 52 Jul 09 2012 RSKRX210 4 10 3 RPDL Integration 4 Peripheral Samples Function RPDL Function Init WDT R_ADC_12_Set R_ADC_12_CreateUnit R_ADC_12_CreateChannel R_ADC_12_Control R CMT Create R WDT Set R INTC CreateExtlnterrupt R WDT Control CB Timer WDT R WDT Oontrol R ADC 12 Read R IO PORT Modify R CMT Control CB WDTOverflow R IO Port Write R20UT0305EG0200 Rev 2 00 Jul 09 2012 Table 4 10 WDT Sample RPDL Integration RENESAS Page 31 of 52 RSKRX210 4 Peripheral Samples 4 11 RTC This sample code demonstrates the usage of the real time clock s functionality by running a timer from a 32 768 KHz clock source The time is displayed on the debug LCD using the 24 hour digital format hh mm ss starting from 00 00 00 4 11 1 Operation 1 The sample initialises the debug LCD and displays the sample name instructions on the screen 2 The sample then calls the Init RTC to initialise the RTC settings and configures two callback functions CB Alarm RTC and CB IHZ RTC 3 The sample enters an infinite while loop which is interrupted every second by the RTC callback function CB_1HZ_RTC This function fetches the time time elapsed from sample start from the RTC unit and displays it on the debug LCD 4 The while loop is interrupted again when the time matches the alarm time The interrupt executes the callback function CB_Al
21. 8 3 RPDL Integration cional 41 5 Additional Information e cesessssssssssesceceqesesssssvescesesesesasssssseeseqsssssssssssescessnnsnsssi i 48 RENESAS RSK RX210 R20UT0305EG0200 Rev 2 00 RENESAS STARTER KIT Jul 09 2012 1 Overview 1 1 Purpose RSK is an evaluation tool for Renesas microcontrollers This manual explains the operation of the sample code provided and its interaction with the Renesas Peripheral Driver Library RPDL The Renesas Peripheral Driver Library hereinafter this library or RPDL is based upon a unified API Application Programming Interface for the microcontrollers made by Renesas Electronics Corporation This manual is not intended to be a tutorial on using RPDL or how RPDL works it simply aims to explain to the reader how the RPDL was used to create the sample code supplied with the RSK For further information regarding RPDL refer to the RPDL API User s Manual supplied with the RSK Alternatively visit the PDG Peripheral Driver Group section of the Renesas website http www renesas com pdg 1 2 Note Regarding Document This document explains by text and diagrams the functionality of the sample code and its interaction with the Renesas Peripheral Driver Library RPDL The RPDL is preliminary and functionally tested to operate with the RSKRX210 sample code only This manual aims to be as clear as possible by matching the reference sample code as c
22. ADConversion R ADC 12 Read R CMT Control R20UT0305EG0200 Rev 2 00 Jul 09 2012 Table 3 1 Tutorial Sample RPDL Integration RENESAS Page 12 of 52 RSKRX210 3 Tutorial Samples 3 2 Application 3 2 1 Description The application sample is intended as a starting platform for the user to write his her own code The sample includes all the necessary initialisation code and configuration settings from previous samples The main function contains no sample code and performs no additional functionality For more information regarding the hardware initialisation performed before the main function starts refer back to 2 R20UT0305EG0200 Rev 2 00 RENESAS Page 13 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 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 4A ADC12 Repeat This sample code demonstrates usage of the on chip analogue to digital converter ADC in group scan repeat mode The sample configures the ADC to repeatedly take readings of the potentiometer voltage RV1 and other analogue input signals available through RSK headers The sample then updates the conversion value displayed on the LCD by periodic interrupts from the timer module 4 1 1 4 1 2 Operation The sample first initialises the de
23. D and displays the sample name instructions on the screen The sample then configures a timer channel to output a 1 KHz periodic square wave with 50 duty The sample then enters an infinite while loop The timer unit will continue to produce the waveform Sequence Diagram Main LCD Init LCD l lt lt Displays the sample l name instructions on the Display LCD debug LCD I I I RAH Init_TimerMode lt lt Configures a timer unit to produce a 1KHz squarewave output gt gt while 1 lt lt Infinite while loop gt gt Figure 4 8 Timer Mode Sequence Diagram 4 8 3 RPDL Integration Function RPDL Function Init_TimerMode R_MTU2_Set R_MTU2_Create R_MTU2_ControlChannel CB_Timer_TimerMode R_IO_PORT_Modiy Table 4 8 Timer Mode Sample RPDL Integration R20UT0305EG0200 Rev 2 00 TENESAS Page 27 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 9 PWM This sample code configures the timer to generate a IKHz waveform with a constantly changing duty cycle The duty cycle begins at 10 and gradually increases to 90 then cycles back to 10 continuously until the user presses switch 1 and freezes the duty cycle The value at this freeze point is displayed on the debug LCD 4 9 1 BO 4 9 2 Operation Before starting this sample the user should refer to the sample code instructions in order to connect the oscilloscope to t
24. D circuit NMI interrupt and a timer Init VDET for updating the LCD gt gt T lt lt Timer interrupt gt gt p lt lt Toggles the user LEDs If gLEDsync flg is set LED3 toggles asynchronously to the other LEDs CB Timer VDET O Otherwise all LEDs toggle together gt gt LOOP lt lt Voltage detect 4 0V interrupt gt gt Callback function triggered by voltage detect interrupt Function sets gLEDsync flg CB LVD2 VDET O z and waits until the voltage goes above 4 0V again gt gt l g 1 lt lt Voltage detect 1 9V NMI interrupt gt gt gt lt lt Callback function triggered by i voltage detect NMI interrupt Function interrupts any callbacks turns offs CB_NMI_VDET LED3 and waits until the voltage e returns above 1 9V then turns LED3 back on before exiting L e 1 l l l l l Figure 4 6 LVD Sequence Diagram U E E E E R20UTO305EG0200 Rev 2 00 TENESAS Page 23 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 6 4 RPDL Integration Function RPDL Function Init_VDET R_LVD_Create R INTC CreateExtlnterrupt R CMT Create CB Timer VDET RIO PORT Modify CB LVD2 VDET R CMT Control R IO PORT Write R LVD GeiStatus R INTC Write CB NMI VDET R IO PORT Write R LVD GeiStatus R_INTC_ControlExtInterrupt R20UT0305EG0200 Rev 2 00 Jul 09 2012 Table 4 6 Low Voltage Detec
25. Switch l l l ti JI l l 1 lt lt SPI receive interrupt gt gt l lt lt Callback function reads L data sent via SPI loopback EER l A 1 T l l I l l l 1 l l Figure 4 13 SPI Loopback Sequence Diagram R20UT0305EG0200 Rev 2 00 LENESAS Page 36 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 13 3 RPDL Integration Function RPDL Function Init SPI R SPI Create R SPI Control R SPI Command R ADC 12 Set R ADC12 Create Unit R ADC 12 CreateChannel CB Switch R ADC12 Control R ADC12 Read R SPI Transfer Table 4 13 SPI Sample RPDL Integration R20UTO305EGO200 Rev 2 00 RENESAS Page 37 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 14 Temperature Sensor This sample code demonstrates usage of the on chip temperature sensor The sample takes repeat readings of the on chip temperature sensor using an ADC channel and converts it into degrees Celsius 4 14 1 Operation O The sample first initialises the debug LCD and displays the sample name instructions 2 It then calls the function Init TempSensor to initialise the ADC module to operate in repeat mode the ADC unit will now continuously take readings of the temperature sensor The function also initialises an interval timer interrupt which calls the CB_Timer_TempSensor callback function every interval 3 The sample then enters an infinite w
26. TPEEEETI TTTEFTETE ITI 8 1 1 O x3 ss eth sisas eh Ss ko o Rie baie AOU AMA E RRM abo hie leat 8 1 2 Not Regarding Document monone selu RR 8 2 RSK Sample Code Concept sera e a a aaa a 9 2 1 Sample Code Struc tile sa T TETTE ITTTTTTTTTTT TTT TI TTT TITT TETTE TTTTTTTTTE eones 9 3 utorial Samples sss sm SS ASE TEA EE 10 3 1 Eke m Ee ti ies 10 3 1 1 Description 10 3 1 2 Operations 11 3 1 3 Sequence Diagram tieien pa A es o EKO ak aes AID ipa eS EEE E 11 3 1 4 RPDIMInte station ss NAS 12 32 NA NAS 13 3 2 1 o NN 13 A Peripheral Samples nanon E SES o 14 4 1 TA DIOJ PAE O o p Pe Pr FEO 14 4 1 1 Operation ss AAA eile EA VAJ PAA GA RA ER IAA eA NJ I SA Aus ie uenia 14 4 1 2 Sequence Dia eram i siso dd 14 4 1 3 RPDE Inte grat One salto dal Adi elimo do 15 42 FAC rle uk OM Ee ANT 16 4 2 1 Operations ssp Sete os a eee nial Be A Rn Re ea eA Sh ata oe ea es 16 4 2 2 Sequence Dia Sram s sss edito espa 16 4 2 3 RPDE Integration eniin oo toc EET TETTE 17 A gt E P NO 18 4 3 1 Descipt oT si 18 4 3 2 Operational ra erin skep os kuna o e o fee erko kla da is 18 4 3 3 Sequence Diagram ess e sts ps im Rel dsd 18 4 3 4 REDE Inte granny testi shes che kusi teed AB pa subs unda aber secteur 19 dado TMA Coons To q Mooh TTT TETTE TTT TTT TEO TTT 20 4 4 1 O e a e o ua 20 4 4 2 SEQUENCE DIA tt til Mes noe dno 20 4 4 3 RPDE Integration ass i os es niko el base ko ee o a 20 Ad D A h Cie iohanied I aie Se a AG alas dee aie aot leech ee
27. TTT TE de sseeroehisebsessdayesee 34 4 12 2 Sequence Didgr m Ten iieiea une secs nA uea ats keen uo on Atte dao 34 4 12 3 O 35 4 13 SPISLOOPDACk comi 36 4 13 1 Operation ao 36 4 132 Sequence Dla CLAIM eiii 36 4 13 3 RED clnte gration aria RA ae Sr RAS eens 37 414 Temperature Sensor sisi sua sus ts ne Gal eee he ens e et A eles ENS 38 4 14 1 Operation piantao 38 4 14 2 sequence Diaerainy sss nih uu on o Re ce 38 4 14 3 RPDE Integrati oi testeo lt eed pr e onde a 39 AAS Anal Compare eterna diri 40 4 15 1 Opera E E TETTE TTT TTT Se ees eee i A ee ee ER te ie 40 4 15 2 Sequence Did Prisoner ss an ess cbs nena a Wee Anode ecient 40 4 15 3 RPDL Inte eration s s nna a vee in ieee ig Sadao eats Heo eI eae ines 41 416 Data Operation Circuit DOC assist Ra SUSA AISA SU DNM OMA 42 4 16 1 Siro e E TITT ETTE TETTE TTT TTT TTT TITT ici 42 4 16 2 Sequence Did fr iseer e nerenin soins go Secpsbeasasesvetssessscubareceeudsuyes Do essa cvehdsease teka desdes lapo pa saonsost oer eerta tasto 42 4 16 3 RPDE te gration NS 43 427 Event ink Controller ELC 2222 4 cians Sis ek eh EA II Se Ee a 44 4 17 1 Uro TT TE TT TET TTT TETTE TTTTTETTE TTT TET TETTE TT TEGI 44 4 17 2 Sequence DIAM ss enen Sn on in en a ei ele en ASRS 44 4 17 3 RPDL NMESTA ON sata t 45 Alo NA A ba ve dn sumero de a o ak eo du 46 4 18 1 Operation S253 ache Sat de ina det bolos cd des ra i es sn us dt ld 46 4 18 2 Sequence DIA STAM cesses se AS orb she rsono ari 46 4 1
28. arm_RTC which turns on LED 1 4 11 2 Sequence Diagram Main LCD RTC Init LCD gt l Displays the sample name instructions on the O Display_LCD debug LCD gt gt a lt lt Initialises the RTC unit gt gt Init RTC q i lt lt RTC 1Hz interrupt gt gt lt lt Callback function is trigger by the RTC 1Hz interrupt Function updates the time CB 1HZ RTC from the RTC unit to the debug LCD gt gt T LOOP while 1 lt lt RTC Alarm interrupt gt gt T I lt lt Callback function is triggered by the RTC alarm Function sets LED1 on gt gt CB Alarm RTC Figure 4 11 RTC Sequence Diagram R20UT0305EG0200 Rev 2 00 TENESAS Page 32 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 11 3 RPDL Integration Function RPDL Function Init_RTC R RTC Create R RTC Control CB 1HZ RTC R RTC Read CB Alarm RTC R IO PORT Write Table 4 11 RTC Sample RPDL Integration R20UT0305EG0200 Rev 2 00 RENESAS Page 33 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 12 IIC Master This sample demonstrates usage of the IIC unit in master mode by performing read and write operations to an EEPROM memory device The sample is configured to work with the following Renesas devices 4 12 1 HN58X245121 IMbit EEPROM 1MHz Operation The sample ini
29. bug LCD and displays the sample name instructions It then calls the function Init_ADC12Repeat to initialise the ADC module to operate in repeat mode the ADC unit will now continuously take readings The function also initialises an interval timer interrupt which calls the CB Timer ADCI2Repeat callback function The sample then enters an infinite while loop The timer interrupt function CB Timer ADCI2Repeat is called every interval and fetches the current AD conversion result The function then displays the result onto the debug LCD The callback function displays a different analogue input reading each time it is called Sequence Diagram Init LCD gt Init ADC12Repeat lt lt Configures the ADC unit and initialises an interval timer interrupt gt gt Display LCD debug LCD Potentiometer Displays the sample name instructions on the lt lt Timer interrupt gt gt T p lt lt Infinite while loop gt gt while 1 lt lt Fetches ADC value and displays result on debug CD gt gt Timer_ ADC12Repeat R20UT0305EG0200 Rev 2 00 Jul 09 2012 Figure 4 1 ADC_Repeat Sequence Diagram RENESAS T l LOOP l l l Page 14 of 52 RSKRX210 4 Peripheral Samples 4 1 3 RPDL Integration Function RPDL Function Init_ADC12Repeat R ADC 12 Set R ADC 12 CreateUnit R ADC 12 CreateChannel
30. e 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 8 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 9 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 u
31. e received character into the CRC registers and fetches the calculated checksum and returns it to the CB_SCIReceive_CRC function The sample returns from the Calculate_CRC function to the callback function and writes a string containing the received character and its checksum to the terminal The sample then returns to the infinite while loop and waits until a key is entered into the terminal again Sequence Diagram Main 1e SCI CRC l Init LCD I La Display instructions on the debug LCD gt gt D l DisplayLCD l l l lam Init CRC lt lt Initialise the CRC and the SCI modules Instructions are sent to the terminal gt gt lt lt SCI data receive interrupt generated gt gt Zi SCI receive callback func gt tion generates CRC checksum of the received character and pa displays it on the terminal gt gt pa E lt lt Infinite while loop gt gt 9 2 lt lt Function generates CRC 2 El checksum from input value gt gt O Calculate CRC o LA a 8 a 6 LOOP t t l l l l l l 1 1 1 Figure 4 3 CRC Sequence Diagram R20UTO305EG0200 Rev 2 00 TENESAS Page 18 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 3 4 RPDL Integration Function RPDL Function Init_CRC R_CRC_Create R SCI Create R SCI Receive R SCI Send CB SCIReceive CRC R SCI GetStatus R SCI Send R SCI Receive Calculate CRC R CRC Write R
32. enesas 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 7 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 application 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 application categorized as Specific or for which the product is not intended where you have failed to obtain the prior written consent 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 Standard Computers offic
33. he correct location The sample initialises the debug LCD and displays the sample name instructions on the screen It then calls the function Init PWM which configures a timer channel to generate an initial periodic 1 KHZ output signal with a 10 duty cycle The function configures the timer to generate an interrupt at the end of each period serviced by the callback function CB Timer PWM The function also configures a switch interrupt and callback function The CB_Timer_PWM callback function increments the duty cycle each time it is executed if the duty cycle is less than 90 otherwise it resets the duty cycle to 10 When the user switch is pressed the callback function CB_Switch_PWM is called The function prevents the duty cycle from changing and displays the current duty cycle on the debug LCD Sequence Diagram ar o Init LCD l Display LCD Instructions are displayed on the debug LCD rr Init PWM Initialises a timer channel for compare match operations gt gt lt lt Interval timer interrupt gt gt lt lt Timer callback function I called on timer interrupts to CB Timer PWM update the duty cycle Switch interrupt The switch callback function stops and captures the timer count which is then displayed on the debug LCD as a CB Switch PWM percentage It also prevents further updates of the timer s period gt gt l l LOOP l I I 1 I l 1 l
34. hile loop The timer interrupt function CB_Timer_TempSensor is called every interval and fetches the current AD conversion result The result is then converted into degrees Celsius and displayed on the debug LCD 4 14 2 Sequence Diagram i a Init LCD l l Displays the sample name instructions on the l Display LCD debug LCD l l l and initialises an interval timer interrupt gt gt Init_TempSensor lt lt Configures the ADC unit lt lt Timer interrupt gt gt lt lt Infinite while loop gt gt nee dere Solis and displays result on CB Timer E debug LCD gt gt TempSensor E a LOOP l l l Figure 4 14 Temperature Sensor Sequence Diagram R20UTO305EGO200 Rev 2 00 RENESAS Page 38 of 52 Jul 09 2012 RSKRX210 4 14 3 RPDL Integration 4 Peripheral Samples Function RPDL Function Init_TempSensor R_RWP_Control R_ADC_12 CreateUnit R_CMT_Create R_TS_Create R_TS_Control CB_Timer_TempSensor R ADC 12 Read R ADC 12 Control Table 4 14 Temperature Sensor Sample RPDL Integration R20UT0305EG0200 Rev 2 00 RENESAS Jul 09 2012 Page 39 of 52 RSKRX210 4 Peripheral Samples 4 15 Analog_Compare This sample code demonstrates usage of the on chip analog comparator module The sample configures a comparator to compare the voltage with a
35. interval period By adjusting the potentiometer the length between WDT resets is varied When the WDT reset interval is too long the watchdog timer will overflow and trigger an interrupt which calls the callback function CB_Overflow_WDT This function sets the LEDs to static displays a watchdog overflow message on the debug LCD and waits in an infinite while loop 4 10 2 Sequence Diagram l Init LCD l lt lt Displays the sample l name instructions on the O l Display LCD debug LCD gt gt l l l l l l 7 l a 1 lt lt Initialises WDT unit ADC unit and an interval timer to Init WDT trigger callback function l CB_Timer_WDT gt gt I l l l l l l y l lt lt Timer interrupt gt gt p l l lt lt Callback function interval timer l Function resets the WDT count e toggles the LEDs fetches the ADC CB_Timer_WDT 5 l result and uses to calculate a new l l timer period gt gt l i l l T 1 LOOP l i l WDT overflow interrupt l lt lt pt gt gt pi lt lt Callback function triggered l l l by WDT overflow interrupt CB Overfl l l l Function displays overflow mO on l l l message on the debug LCD O l l l sets the LEDs as steady on I l and waits in an infinite while loop T l l l l l l l l I l l Figure 4 10 WDT Sequence Diagram R20UTO305EG0200 Rev 2 00 TENESAS Page 30 of
36. lock l unit to create an interrupt every I second and execute the CB RTC T PowerDown callback function gt gt l l l lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt MCU Enters Standby Mode gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt gt z i Real time clock interrupt detected gt lt lt Real time clock interrupt occurs and wakes MCU from sleep Function CB_RTC_PowerDown updates LCD with RTC Program returns to time gt gt while loop and enters standby mode again gt gt LOOP Figure 4 7 Power Down Sequence Diagram R20UT0305EG0200 Rev 2 00 Jul 09 2012 RENESAS Page 25 of 52 RSKRX210 4 7 3 RPDL Integration 4 Peripheral Samples Function RPDL Function Init PowerDown R RTC Create R RTC Control R LPC Create CB RTC PowerDown R RTC Read R CMT CreateOneShot Table 4 7 Power Down Sample RPDL Integration R20UTO305EG0200 Rev 2 00 TENESAS Jul 09 2012 Page 26 of 52 RSKRX210 4 Peripheral Samples 4 8 Timer_Mode This sample code configures the timer to generate 1 KHz waveform The waveform can be seen on the oscilloscope 4 8 1 O 4 8 2 Operation Before starting this sample the user should refer to the sample code instructions in order to connect the oscilloscope to the correct location The sample initialises the debug LC
37. losely as possible There may be some cases however where the function names in the code differ slightly this document This does not change its functionality as described in this manual R20UT0305EG0200 Rev 2 00 RENESAS Page 8 of 52 Jul 09 2012 RSKRX210 2 RSK Sample Code Concept 2 RSK Sample Code Concept 2 1 Sample Code Structure The basic structure of all RSK sample code is shown in Figure 2 1 below The first two functions PowerOn ResetPC and HardwareSetup configure the MCU before the main program code executes Reset PowerOn ResetPC HardwareSetup Hardware setup consists of the following functions ConfigureOperatingFrequency ConfigureOutputPorts EnablePeripheralModules Configurelnterrupts main o Final State Figure 2 1 Sample Code Structure The purpose of the functions included in the HardwareSetup function are detailed in Table 2 1 below Function Name Purpose RPDL Functions Used ConfigureOperatingFrequency Initialises the main MCU bus and R_CGC_Set peripheral clocks as well as any real R CMT CreateOneShot time clocks and PLL settings R_CGC Control ConfigureOutputPorts Configures the MCU port pins as inputs R_IO_PORT_Set or outputs depending on the devices on R lO PORT Write the RSK and the intended function of the A sample code Also sets some pins to suitable initial logic levels EnablePeripheralModules Enables or disables peri
38. memory starting from address 0 when switch SW2 is pressed gt gt Write EERPOM Master o E o Li a 8 E S S E 3 Q 2 7 8 i The contents of an Switch 3 press interrupt EEPROM memory location is t P read and checked against the output data string gt gt Read_EERPOM_Master LOOP Figure 4 12 IIC Master Sequence Diagram R20UT0305EG0200 Rev 2 00 TENESAS Page 34 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 12 3 RPDL Integration Function RPDL Function Init EEPROM Master R IIC Set R IIC Create Write EEPROM Master R IIC MasterSend R CMT CreateOneShot Read EEPROM Master R IIC MasterSend R IIC MasterReceive R CMT CreateOneShot CheckStatus EEPROM Master R IIC GetStatus BusActivity IIC R IO PORT Write Table 4 12 IIC Master Sample RPDL Integration R20UTO305EGO200 Rev 2 00 RENESAS Page 35 of 52 Jul 09 2012 RSKRX210 4 Peripheral Samples 4 13 SPI Loopback This sample code demonstrates usage of the SPI unit by performing a simple loopback test 4 13 1 Operation This sample may require hardware modifications in order to operate Refer to the sample code instructions for further information before proceeding Q The sample first initialises the debug LCD and displays the sample name instructions 2 The Init SPI function is called which initialises
39. nction CB_SCIReceive_Async is called when data is received on the SCI unit When a user enters a character in the terminal program the callback function is called The function fetches the keypress and if the character is a z it sets the gSCI Flag variable to false On all other keypresses it sets the flag to true Once z has been pressed LED1 will turn on and LEDO remain off until another key is pressed to resume transmission 4 2 2 Sequence Diagram Main LCD SCI T g T l Init_LCD gt lt lt Displays sample name instructions on the debug LCD gt gt l O Display LCD l l La J lt lt Initialises the SCI unit in asynchronous mode Init_Async and also configuresa timer to generate interval interrupts gt gt l l l I Timer callback function Timer interrupt generated transmits incrementing 1 p numbers via SCI if l gSCI Flag is true l CB Timer Async Eja LOOP 2 lt lt lt SCI data receive interrupt generated gt gt l 5 T gt j lt lt Receive function fetches the received character and 3 sets the gSCI Flag variable CB SCIReceive to false if its z gt gt Async lt a l l l l l l l l l l Figure 4 2 Async Serial Sequence Diagram R20UTO305EG0200 Rev 2 00 TENESAS Page 16 of 52 Jul 09 2012 RSKRX2
40. nder 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 of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or system manufactured by you 10 Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations 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
41. 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 assumed by the User The RSK is provided by Renesas on an as is basis without warranty of any kind whether express or implied including but not limited to the implied warranties of satisfactory quality fitness for a particular purpose title and non infringement of intellectual property rights with regard to the RSK Renesas expressly disclaims all such warranties Renesas or its affiliates shall in no event be liable for any loss of profit loss of data loss of contract loss of business damage to reputation or goodwill any economic loss any reprogramming or recall costs whether the foregoing losses are direct or indirect nor shall Renesas or its affiliates be liable for any other direct or indirect special incidental or consequential damages arising out of or in relation to the use of this RSK even if Renesas or its affiliates have been advised of the possibility of such damages Preca
42. pheral modules Non RPDL functions only on the MCU not controlled by RPDL as required by the sample code Configurelnterrupts Configures interrupts external hardware R_INTC_CreateExtInterrupt interrupts required by the sample code R_INTC_CreateFastinterrupt Table 2 1 Hardware Setup Functions RPDL functions can not be used to manually enable disable MCU peripherals as this is controlled with the Create Destroy functions for each RPDL group therefore RPDL functions are not required in this section RPDL functions indirectly called by the function Configurelnterrupts R20UTO305EGO200 Rev 2 00 RENESAS Page 9 of 52 Jul 09 2012 RSKRX210 3 Tutorial Samples 3 Tutorial Samples 3 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 3 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 Flash LED Timer ADC Y Static Test while 1 INI Figure 3 1 Tutorial Sample Flow R20UT0305EG02
43. respective companies or organisations Copyright This document may be wholly or partially subject to change without notice All rights reserved Duplication of this document either in whole or part is prohibited without the written permission of Renesas Electronics Europe Limited 2011 2012 Renesas Electronics Europe Ltd All rights reserved 2011 2012 Renesas Electronics Corporation All rights reserved 2011 2012 Renesas Solutions Corp All rights reserved R20UT0305EG0200 Rev 2 00 RENESAS Page 48 of 52 Jul 09 2012 REVISION HISTORY RSK RX210 User s Manual Rev Date Description Page Summary 1 00 Jul 30 2011 First Edition issued 2 00 Jul 09 2012 Updated revision number in footers 5 Added CRC to the list of Abbreviations 26 Deleted R LPC Control reference in Table4 7 37 Table reference text changed from CRC to SPI Added R TS Create and R TS Control to table 4 13 4 to Init TempSensor Added R SCI Control to in table 4 16 3 to function Init DOC RIO GV A o Renesas Starter Kit User s Manual Software Manual Publication Date Rev 2 00 Jul 2012 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
44. rminal via SCI to a set reference integer and reporting the comparison result back to the PC terminal 4 16 1 O O 4 16 2 Operation Before starting the sample the user should connect the RSK to a PC via an RS 232 cable and start the terminal program refer to the instructions in the sample code comments The sample first initialises the debug LCD and displays the sample name instructions It then calls the function Init_DOC which configures the SCI unit to communicate with a PC terminal and configures the SCI unit to execute the callback function CB_SCIRecieve_DOC when data is received It also configures the DOC unit to perform comparisons of an input integer to a reference integer set in the global variable gCompareReference_DOC The sample then enters an infinite while loop When the user enters a key in the PC terminal the callback function CB_SCIReceive_DOC function is called The function fetches the key entered and converts it to an ASCII equivalent integer The function then passes the value to the DOC unit The DOC unit performs a comparison of the user input and the set reference integer and updates the PC terminal indicating whether the input was a match or not The program then returns to the infinite while loop and repeats step 3 on the next user input Sequence Diagram Main LCD SCI Init LCD gt l L lt lt Displays the sample name instructions on the
45. rting the sample remove the debug LCD from the RSK as it is not used in the sample and can skew any power measurement readings Refer to the main low power c file for instructions on measuring the MCU power consumption The sample calls the function Init_LowPower to configure the low power consumption functions It also shuts down any unneeded peripherals to reduce power consumption and configures a switch press interrupt to call the callback function CB_Switch_LowPower The sample then executes the IdleFunction_LowPower This function loops infinitely and flashes LEDO to indicate CPU activity This function is interrupted when a user switch is pressed which calls the CB_Switch_LowPower function This callback function changes the MCU s power mode depending on which switch is pressed SW1 SW2 SW3 Power Mode Normal Power Mode Software Standby Power Mode Normal Operating Mode Low Speed 2 Operating Mode X Operating Mode High Speed Operating mode is preserved from previous setting 4 18 2 Sequence Diagram O Init LowPower o Switch press interrupt p lt lt IdleFunction_LowPower function lt lt Switch press interrupt calls the loops infinitely and flashes LEDO to CB_Switch_LowPower callback indicate CPU activity gt gt function Function changes power CB_Switch mode depending on the switch _LowPower pressed gt gt IdelFunction LowPoweri
46. the SPI unit and configures an SPI receive interrupt callback An ADC unit is configured for single scan operations The function also configures a switch callback function 3 The sample then enters an infinite while loop When the user presses the switch specified see sample code comments the callback function CB Switch is called This callback function takes an ADC reading and transmits it via the SPI loopback 4 The data transmitted in the CB Switch function is received by the loopback SPI and generates an interrupt The SPI receive interrupt calls the CB SPIReceive callback function which fetches the received data and compares it against the original value sent If they match it displays the result on the debug LCD If there is a mismatch between sent and received data an error is reported on the debug LCD 4 13 2 Sequence Diagram Main LCD SPI Init LCD L lt lt Displays the sample l name instructions on the O Display LCD debug LCD display gt gt lt lt Initialise SPI unit configures an SPI receive interrupt and Init_SPI configures a switch interrupt l callback function gt gt T I l l l l l l l yA Switch interrupt lt lt gt gt lt lt Infinite while loop gt gt lt lt Callback function takes l ADC reading and transmits the result via SPI loopback gt gt CB
47. tial voltage to 5V The sample initialises the debug LCD and displays instructions on the screen The sample then calls the Init VDET function which initialises the LVD unit to generate interrupts when VCC drops to 4 0V and 1 9V The function also configures a CMT timer to periodically toggle the user LEDs The sample then enters an infinite while loop The while loop periodically interrupt by the callback function CB_Timer_VDET If the global gLEDsync_flg is set it toggles LEDs LEDO to LED2 synchronously and LED3 asynchronously If gLEDsync flg is not set it toggles all the user LEDs together When the input voltage is lowered to below 4 0V the CB_LVD2_VDET callback function is called by the voltage detect interrupt This function sets the gLEDsync_flg turns off LEDs LEDO to LED2 and waits until the supply voltage returns to over 4 0V When the input voltage is lowered to below 1 9V the CB_NMI_VDET callback function is called by the non maskable voltage detect interrupt This interrupts any other callback functions that may be running This function turns off all the user LEDs and waits until the voltage level rises above 1 9V before exiting 4 6 3 Sequence Diagram Main LCD CMT LVD T A T l Init LCD p l lt lt Displays the sample l name instructions on the O l Display LCD debug LCD l l l lm 5 lt lt Initialises LV
48. tialises the debug LCD and displays the sample name instructions on the screen The sample then enters the main IIC master sequence loop where it first calls the Init EEPROM Master function which configures the IIC unit to operate in master mode The master sequence then waits in an infinite while loop polling the user switch flag When switch SW2 is pressed an EEPROM device write operation is executed using the Write EEPROM Master function The write operation writes the string XXRenesas IC where XX is replaced with an ASCII data identifier which increments with every write operation If the write operation fails the debug LCD displays Error W When switch SW3 is pressed an EEPROM device read operation is executed using the Read EEPROM Master function The first 16 bytes of the EEPROM device s memory are read If the read data matches the expected data string XXRenesas IIC the data identifier XX is displayed on the debug LCD to indicate a successful read operation If the read operation fails the debug LCD displays Error R 4 12 2 Sequence Diagram Main LCD 2C Bus Init LCD Instructions are display p ed on the debug LCD gt gt L l l l DisplayLCD l l l e AJ lt lt The PC unit is configured for master mode gt gt Init_EEPROM_Master A lt lt A data string is written to lt lt Switch 2 press interrupt gt gt an EEPROM
49. tion Sample RPDL Integration RENESAS Page 24 of 52 RSKRX210 4 Peripheral Samples 4 7 Power_Down This sample code configures the MCU s low power consumption s settings and enters the MCU into standby mode The RTC is configured to interrupt and wake the MCU at intervals of 1 second to update the LCD with the time elapsed since the program was started 4 7 1 Operation The sample initialises the debug LCD and displays PWR MODE Power Mode on the first line of the LCD and the current power mode Active on the second line The sample then calls the function Init_PowerDown which configures the low power consumption and real time clock registers 3 The sample then enters an infinite while loop The while loop immediately enters the MCU into standby mode After a second the RTC unit triggers an interrupt which wakes the MCU from standby mode and calls the callback function CB_RTC_PowerDown The function CB RTC PowerDown reads the time from the RTC unit and updates the LCD display with the current time time elapsed since program began The program then returns back to the while loop and repeats step 3 amp 4 infinitely 4 7 2 Sequence Diagram Main LCD RTC Init LCD l gt lt lt Displays the sample i name instructions on the l debug LCD l l Display LCD l i l l l l a l l l Init PowerDown l Configures the real time c
50. triggers an A D conversion when a user presses a switch After the AD conversion completes the ELC unit automatically triggers a port pin to toggle The result of the AD operation is displayed on the debug LCD 4 17 1 Operation This sample may require hardware modifications in order to operate Refer to the sample code instructions for further information before proceeding O The sample first initialises the debug LCD and displays the sample name instructions 2 It then calls the function Init_ELC This function configures the ADC and the ELC units The ELC unit is set to trigger the event of toggling a port pin after each ADC conversions A switch interrupt is also set to call the callblack function CB_Switch_ELC 3 The program then enters an infinite while loop When a user switch is pressed the function CB_Switch_ELC executes If the switch pressed is SW1 the function starts an A D conversion reads the result and converts it to a string The string is then displayed on the LCD The function then returns to the while loop 4 As soon as an A D conversion is completed the ELC toggles the selected port pin without interrupting the CPU 4 17 2 Sequence Diagram Init_LCD l I I Display LCD I Displays the sample name i instructions on the debug LCD l l l I Init ELC l lt lt Initialises the ELC unit to toggle a l l port pin after completion of an AD I l
51. upted with the callback function in step 4 Sequence Diagram Figure 3 2 below shows the program execution flow of the tutorial sample Main LCD LED s Potentiometer Init LCD Displays the sample name instructions on the Display LCD debug LCD display lt lt Wait in function and flash p LEDs 200 times or until switch is pressed Initialise ADC and timer modules for interrupt l l l l l l l l l l Flash LED l l l l l Timer ADC callbacks l l AD conversion interrupt Callback function fetches ADC result sets new timer period based on result and CB ADConversion flashes the LEDs Display the static variable STATIC on the LCD and replace with the string TESTTEST Static Test 7 r l l l l l l l lt lt Infinite while loop gt gt l l l l 6 while 1 l l l l l l l l l Figure 3 2 Tutorial Sequence Diagram R20UT0305EG0200 Rev 2 00 RENESAS Page 11 of 52 Jul 09 2012 RSKRX210 3 Tutorial Samples 3 1 4 RPDL Integration Table 3 1 below details the RPDL functions used in each sample code function shown in the sequence diagram Function RPDL Function Flash_LED R_CMT_Create R_CMT_Destroy Start_Timer R_CMT_Create Start_ADC R_ADC_12 Set R ADC 12 CreateUnit R ADC 12 CreateChannel R ADC 12 Control CB
52. utions 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 equipment off or on you are encouraged to try to correct the interference by one or more of the following measures ensure attached cables do not lie across the equipment reorient the receiving antenna increase the distance between the equipment and the receiver connect the equipment into an outlet on a circuit different from that which the receiver is connected power down the equipment when not is use 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

Download Pdf Manuals

image

Related Search

Related Contents

NRS 1-50 - Gestra AG  User Manual - DVS Informatics  取扱説明書    取扱説明書 - ご家庭のお客さま/大阪ガス  

Copyright © All rights reserved.
Failed to retrieve file