Home

Renesas Starter Kit for RSK+RX64M Code Generator Tutorial Manual

image

Contents

1. Initialise the debug LCD R LCD Init Displays the application name on the debug LCD R LCD Display 0 uint8 t RSK RX64M R LCD Display 1 uint8 t Tutorial R LCD Display 2 uint8 t Press Any Switch while 1U R20UT2930EG0100 Rev 1 00 RENESAS Page 35 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project End user code Do not edit comment generated here Then add the definition for the switch call back get_adc and lcd display adc functions in the user code area for adding at the end of the file as shown below BK KR RR KK KR KKK KK KK KR KKK KK KK RR RR ck ck RR RR RR EER RR RR RK KK KK KK KK KK KKK Function Name cb switch press Description Switch press callback function Sets g_adc_trigger flag Argument none Return value none kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxk static void cb_switch_press void Check if switch 1 or 2 was pressed if g_switch_flag amp SWITCHPRESS_1 SWITCHPRESS_2 set the flag indicating a user requested A D conversion is required g_adc_trigger TRUE Clear flag g switch flag 0x0 BRK KKK KK KKK KR KKK KK EER RR ck ck ck ck ck ck KKK KK RR RR ck ck ck ck ck ck RR KK KK KK RR ck ck ck ck ck ck KKK KK KK End of function cb switch press PK kk ke k oke ok ko RR RR k RR ok ok ok ok ok ok ok ok ok ok ok ok ok ok ok RR okok okok o
2. BE R5F564MLCxFC Microcontroller Repeat these steps to create a new i ex Code Generator Design Tool category folder for Dependencies A CC RX Build Tool gt RX Simulator Debug Tool 5 0 File PI Build tool generated files 1 Code Generator C Source Files 5 3 LCD Code Integration API functions for the Okaya LCD display are provided with the RSK Locate the files ascii h r_okaya_lcd h ascii c and r_okaya_lcd c on the RSK DVD These files can be found in the RSK RX64M_Tutorial project for CubeSuite in the Tutorial folder Copy these files into the C Workspace CG_Tutorial folder e Right click on the C Source Files 1 File in the Project Tree and select Add tl in generated files 4 11 Code Generator gt Add File e Source Files e Browse to the files ascii c and Dependend Add A Adde Add File r okaya lcd c in the mer FTP CAWorkspacelCG Tutorial folder 1 iaj and click Add EN Windows Explorer Menu 4 Add New Category e Repeat the above steps to add the Remove from Project Shift Del files ascii h r okaya lcd h to the Ha Copy Ctrl C Dependencies folder al o 4 Paste Ctrl Code must be inserted in to the user code area in many files in this project in the areas delimited by comments as follows Start user code for xxxxx Do not edit comment generated here End user code Do not edit comment generated here
3. The project may now be run using the debugger as described in 6 When any switch is pressed the program will perform an A D conversion of the voltage level on the ADPOT line and display the result on the LCD panel Return to this point in the Tutorial to add the UART user code 5 5 Debug Code Integration API functions for trace debugging via the RSK serial port are provided with the RSK Locate the files r_rsk_debug h and r_rsk_debug c on the RSK DVD RSK RX64M_Tutorial project for CubeSuite in the Tutorial folder Copy these files into the C Workspace CG_Tutorial folder Import these two files into the project in the same way as the LCD files In the r_rsk_debug h file ensure the following macro definition is included Macro for definition of serial debug transmit function user edits this define SerialDbgWrite R_SCI7_AsyncTransmit This macro is referenced in the r_rsk_debug c file and allows easy re direction of debug output if a different debug interface is used R20UT2930EG0100 Rev 1 00 RENESAS Page 38 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project 5 6 UART Code Integration 5 6 1 SCI Code In the Cubesuite Project Tree expand the Code Generator folder and open the file r_cg_sci h by double clicking on it Insert the following code in the user code area at the end of the file Start user code for function Do not edit comment generated here MD STATUS R SCI6 SPIMast
4. Where xxxx depends on the particular area of code i e function for insertion of user functions and prototypes global for insertion of user global variable declarations or include for insertion of pre processor include directives User code inserted inside these comment delimiters is protected from being overwritten by Code Generator if the user needs to subsequently change any of the Code Generator generated code In the Cubesuite Project Tree expand the Code Generator folder and open the file r cg userdefine h by double clicking on it Insert the following defines in between the user code delimiter comments as shown below R20UT2930EG0100 Rev 1 00 RENESAS Page 29 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project Start user code for global Do not edit comment generated here define TRUE 1 define FALSE 0 End user code Do not edit comment generated here In the Cubesuite Project Tree open the file r cg main c by double clicking on it Insert include r okaya lcd h in between the user code delimiter comments as shown below Start user code for include Do not edit comment generated here include r_ok a lcd h End user code Do not edit comment generated here Scroll down to the main function and insert the highlighted code as shown below into the beginning of the user code area of the main function void main void R MAIN UserInit S
5. 0 Add the following highlighted code to the user code area in the main function void main void R MAIN UserInit Start user code Do not edit comment generated here Initialise the switch module R SWITCH Init Set the call back function when SW1 or SW2 is pressed R SWITCH SetPressCallback cb switch press Initialise the debug LCD R LCD Init Displays the application name on the debug LCD R LCD Display 0 uint8 t RSK RX64M R LCD Display 1 uint8 t Tutorial R LCD Display 2 uint8 t Press Any Switch Start the A D converter R S12ADO Start R20UT2930EG0100 Rev 1 00 RENESAS Page 40 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project while 1U Wait for user requested A D conversion flag to be set if TRUE g_adc_trigger uint16_t adc_result Call the function to perform an A D conversion adc_result get_adc Display the result on the LCD lcd display adc adc result Reset the flag g adc trigger FALSE SW3 is directly wired into the ADTRGOn pin so will cause the interrupt to fire else if TRUE g_adc_complete Get the result of the A D conversion R_S12AD0_Get_ValueResult ADCHANNELO amp adc result Display the result on the LCD lcd display adc adc result Increment the adc count Reset the flag g_adc_complete FA
6. R20UT2930EG0100 Rev 1 00 RENESAS Page 20 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in Select the SCI7 Setting sub tab and configure SCI7 as illustrated in Figure 4 12 Make sure the Start bit edge detection is set as Falling edge on RXD7 pin and the Bit rate is set to 19200 bps All other settings remain at their defaults T Property Si Peripheral Functions Start bit edge Low level on RXD7 pin Falling edge on RXD7 pin Data length setting 9bits 8bits 7bits Parity setting None Even Odd Stop bit length setting 1bt 2bits E Transfer direction setting LSB first MSBiirst Transfer rate setting Transfer clock Internal clock Pt E Bit rate 19200 v bps Actual value 19230 769 Error 0 16 7 Enable modulation duty correction 255 SCK7 pin function SCK7 is not used Noise filter setting C Enable noise filter Noise filter clock Clock signal divided by 1 v 60000000 Hardware flow control setting None cTs RTS CTS7 RTS7 pin P93 Data handling setting Transmit data handling Data handled in interrupt service routine v Receive data handling Data handled in interrupt service routine Interrupt setting TXI7 priority Level 15 highest RXI7 priority Level 15 highest V Enable error inter
7. Software interrupt Priori Level 15 highest E Software intemupt 2 P Level 15 highest NMI setting E NMI pin interrupt alid edge Falling Digital filte No filter 0 IRQO setting 7 IRGO 1 P30 jital f No filter 0 Low level O Level 15 highest IRQ1 setting E IRQ1 P31 Digita No filter 0 Low level Pric Level 15 highest IRQ2 setting 4 IRQ2 Pin P12 Digital filter No filter 0 Valid edge Falling hd Priority Level 15 highest IRQ3 setting IRQ3 P33 Digital filte No filter 0 Low level rio Level 15 highest IRQ4 setting E IRQ4 Pin PBI Digital f No filter 0 Low level i Level 15 highest IRQ5 setting V IRG5 Pin P15 Digital fiter No filter 0 Valid edge Falling r Priority Level 15 highest IDO sokkies Figure 4 3 Interrupt Functions tab Navigate to the Group Interrupts sub tab and ensure that the Group BLO interrupt is selected as shown in Figure 4 4 The Group BLO interrupt is used for SCI Transmit End Interrupts TEl and Reception Error Interrupts ERI as described in 4 3 4 R20UT2930EG0100 Rev 1 00 RENESAS Page 15 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in X f A Property d Peripheral Functions f Generate Code 5 OSE CHA A HADDAD 5 5 So OPP BS E General Group Interrupts Interrupt B A selection qi Group BEO setting Group BEO r Level 15 highest Group BLO set
8. adc result amp 0x000F uart buffer 16 char a lt Ox0A a 0x30 a 0x37 Send the string to the UART R_DEBUG_Print uart_buffer KKK KK KK KK kok k k k kok A k k k kok kok k k k RR ER k kk ok kok k kk kok k kk kok kk k kok kk KK I k ek End of function uart display adc kok Ck Ck kk ss RR ke kk oko o kok o RR k kok o RR k RR kk ke kk RR k kok k oko k oko k kok k kok kok RA I I I ER Select Build Project from the Build menu or press F7 Cubesuite will build the project with no errors The project may now be run using the debugger as described in 6 Connect the RSK G1CUSBO port to a USB port on a PC If this is the first time the RSK has been connected to the PC then a device driver will be installed automatically Open Device Manager the virtual COM port will now appear under Port COM amp LPT as RSK USB Serial Port COMx where x is a number Open a terminal program such as HyperTerminal on the PC with the same settings as for SCI7 see 4 3 4 When any switch is pressed or when c is sent via the COM port the program will perform an A D conversion of the voltage level on the ADPOT line and display the result on the LCD panel and send the result to the PC terminal program via the via SCI7 Return to this point in the Tutorial to add the LED user code 5 7 LED Code Integration Open the file r_cg_main c Add the following declaration to the user code area for includ
9. Ex bur transfer buffer pointer tx num buffer size Return Value status MD_OK or MD_ARGERROR okok ok okok kok kok RR k okok ok RR kok okok k k k kok RR kok k kok kok kok kok kk k kok k k kk k k kk k kk k k kk RR RR REK RR RR RR RR REK A MD STATUS R SCI7 AsyncTransmit uint8 t const tx buf const uintl6 t tx num MD_STATUS status MD_OK clear the flag before initiating a new transmission sci7 txdone FALSE Send the data using the API status R SCI7 Serial Send tx buf tx num Wait for the transmit end flag while FALSE sci7 txdone fe Wait return status BRK KK KK okok okok RR ok ok ok ok ok ok ok ok ok ok ok ok I RR RR RR RR I oke ok RR RR RR RR RR RR RR RR RR RR RR RR ok ok ok ok okok k k okok ok ke e e K End of function R SCI7 AsyncTransmit FER KI kk ko kk RR kk RR kk RE RR REK RR RR RR RR REK RR RR RR RR RR RR ke kk RR RR RR RR REK RR k k RR RR RR RR okok ok ok okok 5 6 2 Main UART code Open the file r_cg_main c Add the following declaration to the user code area for include near the top of the file include r rsk debug h Add the following declaration to the user code area for global near the top of the file Prototype declaration for uart display adc static void uart display adc const uint8 t adc count const uintl6 t adc result Variable to store the A D conversion count for user display static uint8 t adc count
10. Peripheral Interface UART Universal Asynchronous Receiver Transmitter Table of Contents Mel EE ATT 7 1 1 lpo z RE V E EE OR Mam 7 ta FEOS RE ea OE aD kasa EE OR N ER OE RE D ere Tiree 7 MID i 8 3 Project Creation with CubeSuite iese sees ee AA ee tnnt n nnn 9 3 1 e AA re pere ror HM HUM 9 3 2 Greating the Projects ns e eee ei Helia a Fee EE 9 4 Code Generation Using the CubeSuite plug in 11 41 INIO UCUION EE 11 4 2 Gode Generator Tout tuc eee Eie ea epi ddl ee Dep dei Meet ua NOAA 11 43 Gode Generallon du cadi e a p OE NIMA a oe 13 5 Completing the Tutorial Project ee AA enne nnn nnns 26 51 Project Settiigs 25 siam eene ene tee in ees itte e a ee epifc atte 26 5i2 Additional Eolders rein ak ete tn cdm alive E e tt lon 28 5 9 CCD Gode Integration ctc oce aka EI itai due reed alp Ped d tie 29 5 4 Switch Gode IntegratlOn sem rn a LNA is 32 59 Beb g Code IntegratlOri innen n iter due eden d drei MOLEO 38 5 6 UART Gode Integration crei ete ne da 39 5 7 EED Gode Integration iii brote eI era e abge iade ko nea 42 6 Debugging the Project iese AA ee ee nnn ee ee nnn nnns nnn 44 7 Running the Code Generator Tutorial see ee RR ee Re ee ee ee ee ee ee 45 7 1 Running the TUtorlal io ree f ii ds 45 8 Additional Information ee ee ee ee ee ee ee ee ee ee ee ee ee ee 46 sTENESAS RSK RX64M R20UT2930EG0100 Rev 1 00 RENESAS START
11. RR REK RR kk RR RR ke kok kok k REK I kok I I I I FRE RARA RARA okok okok okok okok okok okok okok okok okok okok okok okok okok RE RE RR RR RE RR RR RR RR RE RR RR RR RR RR k k k k e e e e Function Name lcd display adc Description Converts adc result to a string and displays it on the LCD panel Argument uintl6 t adc result Return value none KK kk Ck kk kk kk ok ok ok ok ok ok kk kk kk ok ok ok A ok ok ok okok okok kk Ck kk kk ok ck ck ck ERK ok okok ok ck ck ck kck ck ck ck ck ck ck K RR RR ck ck ck ck ck ck ck KKK static void lcd display adc const uintl6 t adc result Declare a temporary variable uint8_t a Declare temporary character string char lcd buffer 11 ADC XXXH Convert ADC result into a character string and store in the local Casting to ensure use of correct data type a uint8 t adc result amp 0x0F00 gt gt 8 lcd buffer 6 char a lt 0x0A a 0x30 a 0x37 a uint8 t adc result amp 0x00F0 gt gt 4 lcd buffer 7 char a lt 0x0A a 0x30 a 0x37 a uint8 t adc result amp 0x000F lcd buffer 8 char a lt 0x0A a 0x30 a 0x37 Display the contents of the local string lcd buffer R LCD Display 3 uint8 t lcd buffer BOR KKK kk ke kk RR kk ko kk RR RR ke ke kk ke kk RR kk A End of function lcd display adc CK Ck kk ko kk Ck ke kk ko ko kk ke kk RR kk RR kk REK RR
12. duplicate build mode e The new Debug build mode will be added to the Build mode list Click Close Now in the main CC RX Property window under the Common Options tab click on the line containing Build Mode click the pull down arrow and select Debug from the pull down R20UT2930EG0100 Rev 1 00 Jul 21 2014 5 Completing the Tutorial Project n Text Edit Build Mode Settings Selected build mode Build mode list Default Build CC AX Property 4 Build Mode DefaultBuid EI 4 Output File Type and Path Output file type Intermediate file output folder 2TENESAS DefaultBuild Page 27 of 50 RSK RX64M 5 Completing the Tutorial Project e In the Frequently Used Options for N CCX Property a e EI Compile group select the lt BuldMode Tm Optimization Level option and gt CPU select 0 from the pull down We EE EE have now created a Debug build Output file type Execute Module Load Module File mode with no code optimisation Moed DEG BuildModeName i 4 Frequently Used ptions for Compi and will be using the Build mode to addtional include paths Additional include paths 2 create and debug the project System include paths System include paths 0 Macro definition Macro definition 0 Outputs debugging information Yesl debug Optimization level O optimi
13. handlers include r rsk switch h In the same file insert the following code in the user code area inside the function r cmt cmi1 interrupt Stop this timer we start it again in the de bounce routines R CMT1 Stop Call the de bounce call back routine R SWITCH DebounceIsrCallback In the same file insert the following code in the user code area inside the function r cmt cmi2 interrupt Stop this timer we start it again in the de bounce routines R CMT2 Stop Call the de bounce call back routine R SWITCH DebounceIsrCallback 5 4 3 Main Switch and ADC Code In this part of the tutorial we add the code to act on the switch presses to activate A D conversions and display the result on the LCD In 4 3 3 we configured the ADC to be triggered from the ADTRGO pin In this code we also perform software triggered A D conversion from the user switches SW1 and SW2 by reconfiguring the ADC trigger source on the fly once an SW1 or SW2 press is detected In the Cubesuite Project Tree expand the Code Generator folder and open the file r_cg_userdefine h by double clicking on it Insert the following code the user code area resulting in the code shown below Start user code for function Do not edit comment generated here define TRUE 1 define FALSE 0 End user code Do not edit comment generated here Open the file r_cg_main c and insert include r rsk switch h
14. k RR RR kk kk k k End of function R CMT MsDelay A KKK A KKK k kk k k okok ok RR k k ok ok k K kk k k okok kk k K kk kk KAR RRA RARA kk f Select Build Project from the Build menu or press F7 Cubesuite will build the project with no errors The project may now be run using the debugger as described in 6 The program will display RSK X64M Tutorial Press Any Switch on 3 lines in the LCD display 5 4 Switch Code Integration API functions for user switch control are provided with the RSK Locate the files rskrx64def h r_rsk_switch h and r_rsk_switch c on the RSK DVD RSK RX64M Tutorial project for CubeSuite in the Tutorial folder Copy these files into the C Workspace CG_Tutorial folder Import these two files into the project in the same way as the Icd files The switch code uses interrupt code in the files r_cg_icu h r_cg_icu c and r_cg_icu_user c and timer code in the files r_cg_cmt h r_cg_cmt c and r_cg_cmt_user c as described in 4 3 1 and 4 3 2 It is necessary to provide additional user code in these files to implement the switch press release detection and de bouncing required by the API functions in r_rsk_switch c 5 4 1 Interrupt Code In the Cubesuite Project Tree expand the Code Generator folder and open the file r_cg_icu h by double clicking on it Insert the following code in the user code area at the end of the file Start user code for function Do not edit comment ge
15. kk k k kk k kk k RE RR RR RR RR ke REK void R ICU IROSetRisingEdge const uint8 t irg no const uint8 t set r edge Arguments if 1 set r edge ICU IROCR irq_no BYTE 08 ICU IRO EDGE RISING else ICU IRQCR irq no BYTE uint8_t 08 ICU IRO EDGE RISING BR KKK KKK RR KK IK ke RR I RARR ke ER I I RR AS End of function R ICU IROSetRisingEdge vk ok okok ok ok okok ok ok okok okokok ok ok okok okok kk REK kok kk k kok kk kok kok kk k kk k k kk k k kk k kk k REK RR RE RE RR REK RR RR RE RR R20UT2930EG0100 Rev 1 00 Jul 21 2014 RENES Page 33 of 50 RSK RX64M 5 Completing the Tutorial Project Open the r_cg_intp_user file c file and insert the following code in the user code area for include near the top of the file Defines switch callback functions required by interrupt handlers include r_rsk_switch h In the same file insert the following code in the user code area inside the function r_icu_irq2_interrupt Switch 2 callback handler R SWITCH IsrCallback2 In the same file insert the following code in the user code area inside the function r icu ira5 interrupt Switch 1 callback handler R SWITCH IsrCallback1 5 4 2 De bounce Timer Code Open the r cg cmt user c file and insert the following code in the user code area for include near the top of the file Defines switch callback functions required by interrupt
16. 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 e ensure attached cables do not lie across the equipment e reorient the receiving antenna e increase the distance between the equipment and the receiver e connect the equipment into an outlet on a circuit different from that which the receiver is connected e power down the equipment when not in use e consult the dealer or an experienced radio TV technician for help NOTE It is recommended that wherever possible shielded interface cables are used The product is potentially susceptible to certain EMC phenomena To mitigate against them it is recommended that the following measures be undertaken e The user is advised that mobile phones should not be used within 10m of the product when in use e The user is advised to take ESD precautions when handling the equipment The Renesas Starter Kit does not represent an ideal reference design for an end product and does not fulfil the regulatory sta
17. to 24 MHz Size of DataFlash memory KBytes 64 e All other settings can remain at d ain source their defaults Main clock frequency MHz 24 0000 Allow changing of the clock source on writing internal flash memory No 4 Connection with Emulator Power target from the emulator MAX 200mA No Communications method FINE FINE baud rate bps 2000000 e Connect the E1 to the PC and the RSK E1 connector Connect the 5V PSU to the PWR connector on the RSK Connect the Okaya PMOD LCD to the PMOD1 connector e From the Debug menu select Download to start the debug session and download code to the target R20UT2930EGO100 Rev 1 00 EN ESAS Page 44 of 50 Jul 21 2014 RSK RX64M 7 Running the Code Generator Tutorial 7 Running the Code Generator Tutorial 7 1 Running the Tutorial Click the Go button or press F5 to begin the program from the current program counter position It is recommended that you run through the program once first and then continue to the Tutorial manual to review the code Once the program has been downloaded onto the RSK device the program can be executed gt R20UT2930EG0100 Rev 1 00 RENESAS Page 45 of 50 Jul 21 2014 RSK RX64M 8 Additional Information 8 Additional Information Technical Support For details on how to use CubeSuite refer to the manual available on the DVD or from the web site For information about the RX64M group microcontroller refer to the RX64M Group Hardware
18. uk 3 El e d de MEN e i LAN e Porti Port2 Pori3 Porta Ports Porte Port7 Porta Porta Porta Ports Portc Porto Pone PontF Porta Ports E P20 9 Unused In Out Pull up CMOS output y Jutput digh drive output 57 H m Unused In Out Pull up CMOS output C Output 1 High drive output P22 Unused O In Out Pull up CMOS output v Jutput 1 4igh drive output P23 Unused in Out CMOS output Output 1 High drive output A P24 Unusd n Out Pulup CMOS output Output 1 High drive output P25 Unused In Out Pulup CMOS output v T Output 1 C High drive output P26 Unused n Out Pulup CMOS output V Output 1 High drive output P27 5 Unused In Out Pulup CMOS output M V Output 1 V High drive output m D Figure 4 14 VO ports Port2 P45 is used as one of the LCD control lines together with P46 and P47 Configure these lines as shown in Figure 4 15 R20UT2930EG0100 Rev 1 00 RENESAS Page 22 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in T Property Zi Peripheral Functions x f Generate Code O KE at Hh tO AO OA DID DT TA TE M s Porto Porti Pori2 Pona Port Ports For Pori7 Port8 Porta Porta Po
19. 007 A O la Conversion start trigger setting Conversion start trigger Group A A D conversion start trigger pin Conversion start trigger Group B a Compare match with or input capture to MTU0 TGRA ADTRGO pin selection P07 Data registers setting AD converted value addition count 1 time conversion Data placement Right alignment Automatic clearing Disable automatic clearing Data accuracy 12 bit accuracy Dedicated sample and hold circuit setting Input sampling time 8 The input value is invalid ANOOD Self diagnosis conversion time setting Input sampling time 3 667 us Actual value 3 667 AN001 conversion time setting Input sampling time AN002 conversion time setting us Actual value 3 667 Input sampling time AN003 conversion time setting Input sampling time AN004 conversion time setting Input sampling time AN005 conversion time setting Input sampling time 57 e value 3 667 1667 Us Actual value 3 667 167 us Actual value 3 667 3 667 s Actual value 3 667 AN006 conversion time setting Input sampling time 3 667 us Actual value 3 667 AN007 conversion time setting Input sampling time 3 667 s Actual value 3 667 Conversion time setting Total conversion time Group A 4 083 us Total conversion time Group B Note Continuous sampling is disabled Interrupt settin
20. 0EG0100 Rev 1 00 RENESAS Page 13 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in Property l Peripheral Functions NE t Generate Code I amp Zo nia 0 00 d 22 om Main clock oscillator and RTCMCLK setting V Operation I Main clock oscillator forced oscillation only for RTC software standby and deep software standby mode Main clock oscillation source Resonator i y Frequency 24 MHz Oscillator wait time 11000 us Actual value 11090 909 us Oscillation stop detection function Disabled EE PLL circuit setting Operation PLL clock source Main clock oscillator Input frequency division ratio x1 Frequency 240 MHz Sub clock oscillator and RTC RTCSCLK setting Operation Sul Drive capacity for low CL Frequency 32 768 kHz time 225273 me Actual value 2296 182 ms High speed clock oscillator HOCO setting 7 Operation Frequency 16 v MHz Low speed clock oscillator LOCO setting V Operation E Freguency 240 kHz IWDT dedicated low speed clock oscillator IWDTLOCO setting E Operati Frequency 120 kHz RTC clock setting F Operati Clock source Sub clock oscillator v System clock setting Clock source PLL circuit System clock ICLK x12 120 MHz Peripheral module c
21. 3 3 12 bit A D Converter Navigate to the 12 bit A D Converter tab in Code Generator Refer to the screenshot shown in Figure 4 8 and configure the S12ADO as shown We will be using the S12AD0 in 12 bit one shot mode on the AN000 input which is connected to the RV1 potentiometer output on the RSK The conversion start trigger will be via the pin connected to SW3 R20UT2930EG0100 Rev 1 00 RENESAS Page 17 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in Unused Used Operation mode setting Single scan mode Group scan mode Continuous scan mode Double trigger mode setting 0 Disable Enable Self diagnosis setting Mode Unused Voltage used Use VREFHOXO Disconnection detection assist setting Charge setting Unused Period 1 ADCLK Group scan priority setting Group A priority Group A without priority X Group B action Not restarted or continued due to Group A priority AID converted value count setting 9 Addition mode Average mode Analog input channel setting Convert Group A Convert Group B Add Average AD value Dedicated sample and hold ANO00 vi L1 al ai ANOO1 Fi O s AN002 F O LI AN003 a O AN004 A O AN005 al O O ANO006 F O O AN
22. C 7 A 0 D o 24 NESAS RX64M Group Renesas Starter Kit Code Generator Tutorial Manual For CubeSuite RENESAS MCU RX Family RX600 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 hitp www renesas com Renesas Electronics www renesas com Rev 1 00 Mar 2014 Notice 1 Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information 2 Renesas Electronics has used reasonable care in preparing the information included in this document but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included her
23. ER KIT Jul 21 2014 1 Overview 1 1 Purpose This RSK is an evaluation tool for Renesas microcontrollers This manual describes how to use the CubeSuite IDE code generator plug in to create a working project for the RSK platform 1 2 Features This RSK provides an evaluation of the following features e Project Creation with CubeSuite e Code Generation using the code generator plug in e User circuitry such as switches LEDs and a potentiometer The RSK board contains all the circuitry required for microcontroller operation R20UT2930EG0100 Rev 1 00 Page 7 of 50 Jul 21 2014 RENESAS RSK RX64M 2 Introduction 2 Introduction This manual is designed to answer in tutorial form how to use the code generator plug in for the RX family together with the CubeSuite IDE to create a working project for the RSK platform The tutorials help explain the following e Project generation using the CubeSuite e Detailed use of the code generator plug in for CubeSuite e Integration with custom code e Building the project CubeSuite The project generator will create a tutorial project with three selectable build configurations e DefaultBuild is a project with debug support and optimisation level set to two e Debug is a project built with the debugger support included Optimisation is set to zero e Release is a project with optimised compile options producing code suitable for release in a product Some o
24. K RX64M 4 Code Generation Using the CubeSuite plug in 20040055032 8 Bit Timer m Internal clock P02 Bit rate 1500000 v bps Actual value 1500000 Error 0 7 Enable modulation duty comection 255 i SCKE pin function selection Clock output Clock setting Clock delay Clock is not delayed C Enable clock polarity inversion Data handling setting Transmit data handling Data handled in interrupt service routine Interrupt setting TXI6 priority Level 15 highest v TEIG ERIS priority Group BLO Level 15 highest Callback function setting V Transmission end Figure 4 10 SCI6 SPI Master Setting Staying in the Serial Communications Interface tab in Code Generator select the SCI7 sub tab and apply the settings shown in Figure 4 11 In the RSK RX64M SCI7 is connected via a Renesas RL78 G1C to provide a USB virtual COM port as shown in the schematic T Property Si Peripheral Functions di Asynchronous mode Transmission reception v Asynchronous mode Multiprocessor Transmission Clock synchronous mode Transmission Smart card interface mode Transmission Simple IC bus Simple SPI bus Slave transmit receive Pin setting RXD7 SMISO7 SSCL7 P92 TXD7 SMOSI7 SSDA7 P30 m D Figure 4 11 SCI7 General Setting tab
25. LED3 count amp 0x08 LED_ON LED_OFF S EEK Kk ko oko k RR RR RR RR REK RR kk RE RR REK RR kk RE k k k AAA End of function led display count vk kok kok RR ko RR RR RR ok ok ok ok ok ok ok ok ok ok ok ok ok ok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok kok RR kok kok kk kk kk ER ER A Select Build Project from the Build menu or press F7 Cubesuite will build the project with no errors The project may now be run using the debugger as described in 6 The code will perform the same but now the LEDs will display the adc count in binary form R20UT2930EG0100 Rev 1 00 RENESAS Page 43 of 50 Jul 21 2014 RSK RX64M 6 Debugging the Project 6 Debugging the Project In the Project Tree pane right CG Tutorial Project Line G click the RX Simulator Debug Me RSFS64MLCxFC Microcontroller 58 Funct Tool Select Using Debug CC RX Build Tool a Tool gt RX El Serial eM RX Simulator Debug Tool 07 m amp El Build tool generated file 3 p RX ELUTAG a EC Source Files dade y i EJ once RX E20 Serial e Double click RX E1 Serial Z Property 3f r cg macrodriver b 3f r ca cmt user c i r cg icu user c r cg userd Debug Tool to display the RXE1 Seral Property debugger tool properties 4 Internal ROMRAM Under Clock change the main a kioma PT Size of internal RAM KBytes clock frequency
26. LSE End user code Do not edit comment generated here Then add the following function definition in the user code area at the end of the file ORR KR kok ko okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok RR RR RE RR RR RR RR RE RR RR RR I I k k ke k e e e e Function Name uart display adc Description Converts adc result to a string and sends it to the UARTI Argument lt inte t ade count uintl6 t adc result Return value none okokokok ok k kok kok RR RR RE kok RR RR RR RR KCKCKCKCKCKCKCkCk Ck RR RR RR RR KCKCKCKCKCkCk Ck ck ck kk k RR RR EER RR RE ER RR static void uart display adc const uint8 t adc count const uintl6 t adc result Declare a temporary variable char a Declare temporary character string static char uart_buffer ADC xH Value xxxH r n Convert ADC result into a character string and store in the local Casting to ensure use of correct data type a char adc count amp 0x000F uart buffer 4 char a lt Ox0A a 0x30 a 0x37 a char adc result amp 0x0F00 gt gt 8 uart buffer 14 char a lt 0x0A a 0x30 a 0x37 a char adc result amp 0x00F0 gt gt 4 uart buffer 15 char a lt 0x0A a 0x30 a 0x37 R20UT2930EG0100 Rev 1 00 RENESAS Page 41 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project a char
27. M0409000 cg srcXr cg vect h was generated M0409000 cg srcXr cg hardware setup c was generated d M0409000 cg srcXr cg macrodriver h was generated d M0409000 cg srcXr cg userdefine h was generated M0409000 cg srcXr cg cgc c was generated d M0409000 cg srcXr cg cgc user c was generated d M0409000 cg srcXr cg cgc h was generated M0409000 cg srcXr cg icu c was generated d M0409000 cg srcXr cg icu user c was generated d M0409000 cg srcXr cg icu h was generated d M0409000 cg srcXr cg port c was generated l M0409000 cg srcXr cg port user c was generated d M0409000 cg srcXr cg port h was generated M0409000 cg srcXr cg cmt c was generated sal M0409000 cg srcXr cg cmt user c was generated d M0409000 cg srcXr cg cmt h was generated d M0409000 cg srcXr cg sci c was generated J M0409000 cg srcXr cg sci user c was generated d M0409000 cg srcXr cg sci h was generated d M0409000 cg srcXr cg slZad c was generated d M0409000 cg srcXr cg s12ad user c was generated M0409000 cg srcXr cg s12ad h was generated d M0409003 The operation of generating file was successful d EOF Figure 4 16 Code generator console Figure 4 17 shows the Code Generator Files in the Project Tree pane In the next section the CG_Tutorial project will be completed by adding user code into these files and adding new source files to the project R20UT2930EG0100 Rev 1 00 RENESAS Page 24 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Usin
28. Manual For information about the RX assembly language refer to the RX Family Software Manual Technical Contact Details Please refer to the contact details listed in section 9 of the Quick Start Guide General information on Renesas microcontrollers can be found on the Renesas website at http www renesas com Trademarks All brand or product names used in this manual are trademarks or registered trademarks of their respective companies or organisations Copyright This document may be wholly or partially subject to change without notice All rights reserved Duplication of this document either in whole or part is prohibited without the written permission of Renesas Electronics Europe Limited 2014 Renesas Electronics Europe Limited All rights reserved 2014 Renesas Electronics Corporation All rights reserved 2014 Renesas Solutions Corp All rights reserved R20UT2930EG0100 Rev 1 00 RENESAS Page 46 of 50 Jul 21 2014 REVISION HISTORY RSK RX64M Code Generator Tutorial Manual Date Description Page Summary Jul 21 2014 First Edition issued Renesas Starter Kit Manual Code Generator Tutorial Manual Publication Date Rev 1 00 Jul 21 2014 Published by Renesas Electronics Corporation SALES OFFICES sTENESAS 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 el el D
29. Page 30 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project MD_OK or MD_ARGERROR kok kok k k kok o kok o RR RR KERR ke kk RR RR RR RR REK RR RR RR RR ke kk RR RR RR RR ke kk RR k k kok k RR RR RA ok okok RR RR MD STATUS R_SCI6_SPIMasterTransmit uint8 t const tx buf const uintl16 t tx num MD_STATUS status MD_OK clear the flag before initiating a new transmission sci6 txdone FALSE Send the data using the API status R SCI6 SPI Master Send tx buf tx num Wait for the transmit end flag while FALSE sci6 txdone Wait return status kok k k k k k k k k RK KKK KK RK KKK KKK KK RK KKK KK ck ck KK KK RK KK KK KK End of function R_SCI6_SPIMasterTransmit FAK KK ARK ERK RR RR ER RR RR A RR RR RR ER RR RR RE RR RR RE ER RR RR EE RR RR RE ER RR RR ER RR RR RE ER RR This function uses the transmit end callback function to perform flow control on the SPI transmission to the LCD and is used as the main API call in the LCD code module 5 3 2 CMT Code The LCD code needs to insert delays to meet the timing requirements of the display module This is achieved using the dedicated timer which was configured using Code Generator in 4 3 2 Open the file r_cg_cmt h and insert the following code in the user area for function at the end of the file Start user code for function Do not edit comment generated here End user code Do not edit comment genera
30. RR RR kk ke kk Ck kk RR RR REK Ck ke k k I ke RR RE ok kk k ER RR EX RE Open the file r cg s12ad h by double clicking on it Insert the following code in the in the user code area for function resulting in the code shown below Start user code for function Do not edit comment generated here End user code Do not edit comment generated here Open the file r cg s12ad c by double clicking on it Insert the following code in the in the user code area for adding at the end of the file resulting in the code shown below Start user code for adding Do not edit comment generated here R20UT2930EG0100 Rev 1 00 RENESAS Page 37 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project End user code Do not edit comment generated here Open the file r_cg_s12ad_user c and insert the following code in the in the user code area for global resulting in the code shown below Start user code for global Do not edit comment generated here End user code Do not edit comment generated here Insert the following code in the in the user code area of the r s12ad0 interrupt function resulting in the code shown below static void r_sl2ad0_interrupt void Start user code Do not edit comment generated here End user code Do not edit comment generated here Select Build Project from the Build menu or press F7 Cubesuite will build the project with no errors
31. RSK RX64M User s R20UT2590EG hardware Manual Tutorial Provides a guide to setting up RSK environment RSK RX64M R20UT2591EG running sample code and debugging programs Tutorial Manual Quick Start Guide Provides simple instructions to setup the RSK and RSK RX64M Quick R20UT2592EG run the first sample Start Guide Code Generator Provides a guide to code generation and importing RSK RX64M Code R20UT2930EG Tutorial into the CubeSuite IDE Generator Tutorial Manual Schematics Full detail circuit schematics of the RSK RSK RX64M R20UT2589EG Schematics Hardware Manual Provides technical details of the RX600 RX600 Group R01UH0377EJ microcontroller Hardware Manual 2 List of Abbreviations and Acronyms Abbreviation Full Form ADC Analog to Digital Converter API Application Programming Interface Compare Match Timer COMmunications port referring to PC serial port Central Processing Unit Digital Versatile Disc On chip Debugger Graphical User Interface Integrated Development Environment Interrupt Request line Liquid Crystal Display Light Emitting Diode Micro controller Unit Most Significant Bit PC Personal Computer Pmod Digilent Pmod Compatible connector PmodTM is registered to Digilent Inc Digilent Pmod Interface Specification Link valid at 26Jun2013 PLL Phase locked Loop RSK Renesas Starter Kit Plus SCI Serial Communications Interface SPI Serial
32. Selangor Darul Ehsan Malaysia 60 3 7955 9390 Fax 60 3 7955 9510 Renesas Electronics Korea Co Ltd 12F 234 Teheran ro Gangnam Gu Seoul 135 080 Korea el 82 2 558 3737 Fax 82 2 558 5141 Renesas Electronics Corporation EE 2014 Renesas Electronics Corporation All rights reserved Colophon 2 0 RX64M Group ENESAS Renesas Electronics Corporation R20UT2930EG0100
33. 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 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
34. at the 4 Frequently Used Options for Link bottom of the window pane For Using raise TT EG the Outputs debugging information VU te ee option select No nodebug Ea er EE EER Selects whether to output debugging information Reset the build mode back to This corresponds to the debug and nodebug options of the compiler Debug using the Build Mode pull down control e From the menus select File gt Save All to save all project settings 5 2 Additional Folders e Before new source files are added to the project we will create two so aL UR CG Tutorial Property additional folders in the CubeSuite Ne ER Build CG Tutorial Em Project Tree a ban rapid dE Rebuild CG Tutorial uni e Inthe Project Tree pane right click Sl RX Simulator Deb LA Clean CG Tutorial the CG Tutorial project and select p TAL Open Folder with Explorer Add gt Add New Category 1 1 Code Generato El Windows Explorer Menu Add Si LR Add Subproject Wf Set CG Tutorial as Active Project ER Add New Subproject 7 Save Project and Development Tools as Package Y Add File By Paste Ctrl V 3 Add New File Sj Rename r qu Add New Catgory R20UT2930EG0100 Rev 1 00 RENESAS Page 28 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project e Rename the newly created New f CG Tutorial Project Category folder to C Source Files
35. crocontroller list Using microcontroller control scroll down to RX64M and AA Search microcontroller Update expand the tree control by clicking dl RSFSGAMLCAFE 144pin 2 Product Name RSFS64MLCAFC Select EE dos SEA E e uro H p n chip sizelbytes R5F564MLCxFC 176pin N ASFSGAMLCXFP 1OOpin Additional Information Package PLOPO178KB A N ASFS64MLCxLC 177pin N REFBE4MLCxLJ 100pin E R5F564MLCxLK 145pin J R5F564MLDxBG 175pin ME R5F564MLDxFB 144pin a ECAR DUCO TO e Ensure that in the Kind of project pull down Empty Application CC RX is selected e Choose an appropriate name and location for the project then click seloj prope Empty SC Create l Project name CG Tutorial Place C Workspace v Browse Y Make the project folder C Workspace CG_Tutorial CG_Tutorial mtpj F Pass the file composition of an existing project to the new project Project to be passed l Browse Copy composition files in the diverted project folder to a new project folder Cee Cs R20UT2930EG0100 Rev 1 00 RENESAS Page 9 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in e CubeSuite will create the project ES CG Tutorial CubeSuite ProjectTree will be found in the left hand Project Tree window pane NM Stat b kd files and a Code Generator node File Edit View Project Build Debug To
36. e C source file select C99 lang c99 as shown opposite Select the Link Options tab at the bottom of the properties window pane Under Section gt ROM to RAM mapped section add the three mappings as shown opposite R20UT2930EG0100 Rev 1 00 Jul 21 2014 CC AX Property 4 BuildMode Build mode DefaultBuild 4 CPU Instruction set architecture Uses floating point operation instructions Endian type for data Rounding method for floating point constant operations Handling of denormalized numbers in floating point constants Precision of the double type and long double type Replaces the int type with the short type Sign of the char type Sign of the bit field type Selects the enumeration type size automatically Order of bit field members Assumes the boundary alignment value for structure members is 1 Enables C exceptional handling function try catch and throw Enables the C exceptional handling function dynamic cast and typeid General registers used only in fast interrupt functions Branch width size Base register for ROM Base register for RAM Address value of base register that sets the address value Register of base register that sets the address value a m ETA Build mode Selects the build mode name to be used during build 4 Source Language of the C source file Language of the C source file Additional include paths System include paths gt Include files at the head of compiling uni
37. e near the top of the file include rskrx64mdef h Add the following declaration to the user code area for global near the top of the file Prototype declaration for led_display_count static void led_display_count const uint8_t count Add the following highlighted code to the user code area in the main function void main void R MAIN UserInit Start user code Do not edit comment generated here Initialise the switch module R SWITCH Init Set the call back function when SW1 or SW2 is pressed R SWITCH SetPressCallback cb switch press Initialise the debug LCD R LCD Init Displays the application name on the debug LCD R LCD Display 0 uint8 t RSK RX64M R LCD Display 1 uint8 t Tutorial R LCD Display 2 uint8 t Press Any Switch Sart the A D converter R S12ADO Start Set up SCI7 receive buffer and callback function R SCI7 Serial Receive uint8 t amp g rx char 1 Enable SCI7 operations R SCI7 Start while 1U uint16 t adc result R20UT2930EG0100 Rev 1 00 RENESAS Page 42 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project Wait for user requested A D conversion flag to be set SW1 or SW2 if TRUE g_adc_trigger Call the function to perform an A D conversion adc result get adc Display the result on the LCD lcd display adc adc result Increm
38. ein 3 Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others 4 You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from such alteration modification copy or otherwise misappropriation of Renesas Electronics product 5 Renesas Electronics products are classified according to the following two quality grades Standard and High Quality The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below Standard Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots etc High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anticrime systems and safety equipment etc Renesas Electronics products are neither i
39. ent the adc count and display using the LEDs if 16 adc count adc count 0 Send the result to the UART uart display adc adc count adc result Reset the flag g adc trigger FALSE SW3 is directly wired into the ADTRGOn pin so will cause the interrupt to fire else if TRUE g_adc_complete Get the result of the A D conversion R S12ADO Get ValueResult ADCHANNELO amp adc result Display the result on the LCD lcd display adc adc result Increment the adc count and display using the LEDs if 16 adc count adc count 0 Send the result to the UART uart display adc adc count adc result Reset the flag g adc complete FALSE End user code Do not edit comment generated here Then add the following function definition in the user code area at the end of the file BRK KKK KKK KK RR KKK KK KKK AA Function Name led_display_count Description Converts count to binary and displays on 4 LEDS0 3 Argument rnt8 t count Return value none FAK KK REKE R RR RE RR RR RR ER RR RR RE RR RR RR EK RR RR RE KERR RR ER RR RR A RR RR RR EK RR RR AA RR ee static void led display count const uint8 t count Set LEDs according to lower nibble of count parameter LEDO count amp 0x01 LED ON LED OFF LED1 count amp 0x02 LED_ON LED_OFF LED2 count amp 0x04 LED_ON LED_OFF
40. erTransmit uint8 t const tx buf const uint16 t tx num End user code Do not edit comment generated here Open the file r cg sci user c Insert the following code in the user area for global near the beginning of the file Start user code for global Do not edit comment generated here Flag used locally to detect transmission complete static volatile uint8 t sci6_txdone End user code Do not edit comment generated here In the same file insert the following code in the user code area inside the r sci7 callback transmitend function static void r sci 7 callback transmitend void Start user code Do not edit comment generated here End user code Do not edit comment generated here c In the same file insert the following code in the user code area inside the r sci7 callback receiveend function static void r sci7 callback receiveend void Start user code Do not edit comment generated here End user code Do not edit comment generated here ae At the end of the file in the user code area for adding add the following function definition BORK k k k k k k k RK KK ok okok okok KKK KK KK KK KK KKK KK KK Function Name R SCI7 AsyncTransmit R20UT2930EG0100 Rev 1 00 RENESAS Page 39 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project Description This function sends SCI7 data and waits for the transmit end flag Arguments S
41. erator 4 2 Code Generator Tour In this section a brief tour of Code Generator is presented For further details of the Code Generator paradigm and reference refer to the Application Leading Tool Common Operations manual r20ut2663ej0100 Code Generator pdf Application Leading Tool is the stand alone version of Code Generator and this manual is In the Project Tree pane expand the Code Generator node and double click the Peripheral Functions node The CubeSuite main window will now contain a Peripheral Functions tab with the Initial View as show in Figure 4 1 R20UT2930EG0100 Rev 1 00 RENESAS Page 11 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in File Edit View Project Build Debug Tool Window Help B ser Ada Xan 9 e AAR M i Gg Gg DefaultBuild j 91 LIE TE IF 2392 Hroiectii eo A X F Property S Peripheral Functions x 5 mom a HA Se p D de 2 o a 8 fe Generate Code Z I EKBA Sz OOO A Fe DT BI EA A Z f CG Tutorial Project f sing Block diagram 3 TM RSFSSAMLCAEC Microcontroller Main clock oscillator and RTCMCLK setting e Code Generator Design Tool E V Operation E Main clock oscillator forced oscillation Main clock oscillation source Resonator hd Ex Voltage Detection Circuit iw Clock Frequency Accuracy Mea Frequency 24 MHz Low Power Consumption Oscillator wait time 11000 us Actual value 11090 909 ps E W I
42. es GUI features for configuration of MCU sub systems Once the user has configured all required MCU sub systems and peripherals the user can click the Generate Code button resulting in a fully configured CubeSuite project that builds and runs without error Navigation to the MCU peripheral configuration screens may be performed by double clicking the required function in the Project Tree gt Project Name gt Peripheral Function on the left It is also possible to see a preview of the code that will be generated for the current peripheral function settings by double clicking the required function in the Project Tree gt Project Name gt Code Preview on the left R20UT2930EG0100 Rev 1 00 RENESAS Page 12 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in 4 3 Code Generation In the following sub sections the reader is guided through the steps to configure the MCU for a simple project containing interrupts for switch inputs timers ADC and a UART 4 3 1 Clock Generator Figure 4 2 shows a screenshot of Code Generator with the Clock Generator function open Click on the Clock setting sub tab Configure the system clocks as shown in the figure In this tutorial we are using the on board 24 MHz crystal resonator for our main clock oscillation source and the PLL circuit is in operation The PLL output is used as the main system clock and the divisors should be set as shown in Figure 4 2 R20UT293
43. f the illustrative screenshots in this document will show text in the form RXxxx These are general screenshots and are applicable across the whole RX family In this case simply substitute RXxxx for RX64M These tutorials are designed to show you how to use the RSK and are not intended as a comprehensive introduction to the CubeSuite debugger compiler toolchains or the E1 emulator Please refer to the relevant user manuals for more in depth information R20UT2930EG0100 Rev 1 00 Page 8 of 50 Jul 21 2014 RENESAS RSK RX64M 4 Code Generation Using the CubeSuite plug in 3 Project Creation with CubeSuite 3 1 Introduction In this section the user will be guided through the steps required to create a new C project for the RX64M MCU ready to generate peripheral driver code using Code Generator This project generation step is necessary to create the MCU specific project and debug files 3 2 Creating the Project e Start Cubesuite by selecting it Create New Project l A ject can b ted from the Start Menu Cubesuite GO A re ios can ako be crested by reusing the file configuration registered to an existing project will show the Start Page Use the EJ GO button to create a new project Onen Fxistina Proiect 3 s r A O Di e Inthe Create Project dialog select Create Project RX from the Microcontroller pull down Microcontroller RX m e n the Using Mi
44. g Y Enable AD conversion end interrupt S12ADI0 Priority Priority Level 15 highest Y Enable AD conversion end interrupt for group B S12GBADIO I Figure 4 8 A D Converter tab R20UT2930EG0100 Rev 1 00 Jul 21 2014 RTENESAS Page 18 of 50 RSK RX64M 4 Code Generation Using the CubeSuite plug in 4 3 4 Serial Communications Interface Navigate to the Serial Communications Interface tab in Code Generator select the SCI6 sub tab and apply the settings shown in Figure 4 9 In the RSK RX64M SCI6 is used as an SPI master for the Okaya Pmod LCD on the PMOD1 connector as shown in the schematic ES Property S l Peripheral Functions LZ lm Yo j L scie sciz scn2 X BAT I MAT ETE En scia scia scis Clock synchronous mode Smart card interface mode Simple IIC bus Simple SPI bus Pin setting TXD6 SMOSI6 SSDA6 Transmission Transmission Transmiss ion Transmission Master transmit only P01 m m Figure 4 9 SCI6 General Setting tab Select the SCI6 Setting sub tab and configure the SPI Master as illustrated in Figure 4 10 Make sure the Transfer direction setting is set to MSB first and the Bit rate is set to 1500000 All other settings remain at their defaults R20UT2930EG0100 Rev 1 00 Jul 21 2014 RTENESAS Page 19 of 50 RS
45. g the CubeSuite plug in Project Tree 2 0o 8 c ff CG Tutorial Project a R5F564MLCxFC Microcontroller Code Generator Design Tool CC RX Build Tool ex RX Simulator Debug Tool amp D File TI Build tool generated files EER r cg main c r cg dbsct c r cg intprg c c r cg resetprg c r cg sbrk c ej r_cg_vecttbl c ba r cg hardware setup c IB r cg cgc c E r cg cgc user c BJ reg icu c BJ r eg icu user c r_cg_port c BJ r cg port user c BJ reg cmt c BJ r cg cmt user c r cg sci c BJ r cg sci user c e r_cg_sl2ad c j LA r cg sl2ad user c E kiel h r cg sbrk h E ml n r cg stacksct h E h r cg vect h hd r cg macrodriver h Ra r cg userdefine h LAJ r eg cgeh lt r cg icu h h r eg port h h r cg cmt h aj r cg sci h hd r cg sl2ad h n x Figure 4 17 Code Generator Files in the Project Tree R20UT2930EG0100 Rev 1 00 RENESAS Page 25 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project 5 Completing the Tutorial Project 5 1 Project Settings In the Project Tree pane select CC RX Build Tool The build properties will appear in the main window CubeSuite creates a single build configuration called Default Build for the project This has standard code optimisation turned on by default Select the Compile Options tab at the bottom of the properties window pane Under Language of th
46. ilitary applications or use by the military including but not limited to the development of weapons of mass destruction When exporting the Renesas Electronics products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations 10 It is the responsibility of the buyer or distributor of Renesas Electronics products who distributes disposes of or otherwise places the product with a third party to notify such third party in advance of the contents and conditions set forth in this document Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics products 11 This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics 12 Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics 2012 4 Disclaimer By using this Renesas Starter Kit RSK the user
47. in the user code area for include resulting in the code shown below Start user code for include Do not edit comment generated here include r okaya lcd h R20UT2930EG0100 Rev 1 00 RENESAS Page 34 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project End user code Do not edit comment generated here Next add the switch module initialisation function call highlighted in the user code area inside the main function resulting in the code shown below void main void R MAIN UserInit Start user code Do not edit comment generated here Initialise the debug LCD R LCD Init Displays the application name on the debug LCD R LCD Display 0 uint8 t RSK RX64M R LCD Display 1 uint8 t Tutorial R LCD Display 2 uint8 t Press Any Switch while 1U End user code Do not edit comment generated here us In the same file insert the declarations in the user code area for global resulting in the code shown below Start user code for global Do not edit comment generated here End user code Do not edit comment generated here Next add the highlighted code below in the user code area inside the main function and the code inside the While loop resulting in the code shown below void main void R MAIN UserInit Start user code Do not edit comment generated here Initialise the switch module R SWITCH Init
48. kok okok okok okok okok okok okok okok okok okok RR RR RR k e ek ee e e e A kk k k k k k k k kok RK KK KK okok okok kk kk kk kk ck kk ke KKK EE RR KKK KKK Function Name get_adc Description Reads the ADC result converts it to a string and displays kaj it on the LCD panel Argument none Return value uintl6 t adc value vk kok k k okok RR RR okok okok okok okok okok okok RR RR RR RR RR RR RR RR RR RE ko I ko RR RR I RR RR ER IA ER ER ok k ke e ke e ke e ER static uintl16 t get adc void A variable to retrieve the adc result uintl6 t adc result Stop the A D converter being triggered from the pin ADTRGOn R_S12AD0_Stop Start a conversion R S12ADO SWTriggerStart Wait for the A D conversion to complete while FALSE g adc complete R20UT2930EG0100 Rev 1 00 RENESAS Page 36 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project Wait Stop conversion R S12AD0 SWTriggerStop Clear ADC flag g adc complete FALSE R S12AD0 Get ValueResult ADCHANNELO amp adc result Set AD conversion start trigger source back to ADTRGOn pin R S12ADO Start return adc result BORK KKK okok RR okok okok okok okok okok okok okok okok ke okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok okok I e ke ke ke e e ek x End of function get adc ok IK RR RR I RR EK RR RR RR RR RR RR ke k oko
49. lock PCLKA x 1 2 120 MHz Peripheral module clock PCLKB x 14 60 MHz Peripheral module clock for ADC PCLKC x14 60 MHz Peripheral module clock for ADC PCLKD x14 60 MHz Extemal bus clock BCLK x 1 4 v 60 MHz Flash IF clock FCLK x14 e MHz USB clock UCLK x 15 48 MHz BCLK pin output setting Operation L1 put Clock output source BCLK ly SDCLK pin output setting C Operation a Figure 4 2 Clock setting tab Proceed to the next section on Interrupt R20UT2930EG0100 Rev 1 00 RENESAS Page 14 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in 4 3 1 Interrupt Controller Unit Referring to the RSK schematic SW1 is connected to IRQ5 P15 and SW2 is connected to IRQ2 P12 SW3 is connected to directly to the ADCTRGOn and will be configured later in 4 3 3 Navigate to the Interrupt Controller Unit node in Code Generator and in the General tab configure these two interrupts as falling edge triggered as shown in Figure 4 3 below Property Zl Peripheral Functions x El Generate Code D ee o ss OD LO A7 MBT E 1 Group Interrupts Interrupt B A selection a Fast interrupt setting E Fast interrupt ntemupt source BSC BUSERR vect 16 Software interrupt setting
50. ment delimiters Start user code for adding Do not edit comment generated here End user code Do not edit comment generated here Code Generator will locate these comment delimiters and preserve any custom code inside the delimiters on subsequent code generation operations This is useful if after adding custom code the user needs to re visit Code Generator to change any MCU operating parameters By following the steps detailed in this Tutorial the user will generate a Cubesuite project called CG_Tutorial The fully completed Tutorial project is contained on the DVD and may be imported into Cubesuite by following the steps in the Quick Start Guide This Tutorial is intended as a learning exercise for users who wish to use the Code Generator to generate their own custom projects for Cubesuite The CG_Tutorial project uses interrupts for switch inputs the ADC module the Compare Match Timer CMT the Serial Communications Interface SCI and uses these modules to perform A D conversion and display the results via the Virtual COM port to a terminal program and also on the LCD display on the RSK Following a tour of the key user interface features of Code Generator in 4 2 the reader is guided through each of the peripheral function configuration dialogs in 4 3 In 5 the reader is familiarised with the structure of the template code as well as how to add their own code to the user code areas provided by the code gen
51. ms This timer is used as our short switch de bounce timer later in this tutorial R20UT2930EG0100 Rev 1 00 RENESAS Page 16 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in P Property ed Peripheral Functions x f Generate Code a kej bz sie 0 0 0 00 0 OD PP T Te PEAK CMT2 cura Compare match timer operation setting Unused Used E Count clock setting PCLK 8 PCLK 32 PCLK 128 PCLK 512 Interval value setting Interval value 20 ms v Actual value 20 Interrupt setting V Enable compare match interupt CMI1 Priority Level 10 Figure 4 6 CMT1 tab Navigate to the CMT2 sub tab and configure CMT2 as shown in Figure 4 7 This timer is configured to generate a High priority interrupt after 200ms This timer is used as our long switch de bounce timer later in this tutorial FE Property Cu Peripheral Functions x f Generate Code 5 I db Ez a 3b hon zl se DO 9 9270 45 CMTO CMT1 CMT2 cura E Compare match timer operation setting Unused Used Count clock setting PCLK 8 PCLK 32 PCLK 128 9 PCLK 512 Interval value setting Interval value 200 ms w Actual value 200 004267 Interrupt setting Enable compare match interupt CMI2 Priority Level 10 Figure 4 7 CMT2 tab 4
52. ndards 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 how to use Application Leading Tool Code Generator for RX together with the CubeSuite IDE to create a working project for the RSK platform It is intended for users designing sample code on the RSK platform using the many different incorporated peripheral devices The manual comprises of step by step instructions to generate code and import it into CubeSuite but does not intend to be a complete guide to software development on the RSK platform Further details regarding operating the RX64M microcontroller may be found in the Hardware Manual and within the provided sample code Particular attention should be paid to the precautionary notes when using the manual These notes occur within the body of the text at the end of each section and in the Usage Notes section The revision history summarizes the locations of revisions and additions It does not list all revisions Refer to the text of the manual for details The following documents apply to the RX64M Group Make sure to refer to the latest versions of these documents The newest versions of the documents listed may be obtained from the Renesas Electronics Web site Document Type Description Document Title Document No User s Manual Describes the technical details of the RSK
53. nerated here End user code Do not edit comment generated here R20UT2930EG0100 Rev 1 00 RENESAS Page 32 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project Now open the r_cg_icu c file and insert the following code in the user code area at the end of the file BOR KKK kkk REK RR RR RR k k k k k k k k k k k RR RR RR k k k RR k k kk k I k k RR k kk k kk k kok ok ok k k ok okok I kok ok ok okok kk k k Function Name R_ICU_IRQIsFallingEdge Description his function returns 1 if the specified ICU IRO is set to falling edge triggered otherwise 0 Arguments uint8 t irg no Return Value 1 if falling edge triggered 0 if not vk ka ok okok kok kok RR kok okok ok kok kok okok k k ko kok kok kok okok okok okokok kok kk k kok kok kk k k kk k kk k k kk k kk k k kk kk RE RR RE RR uint8 t R ICU IROIsFallingEdge const uint8 t irg no uint8_t falling_edge_trig 0x0 if ICU IROCR irgq no BYTE 04 ICU IRO EDGE FALLING falling_edge_trig 1 return falling_edge_trig E E K dk KKK RR RARR RR REK RR RR RR RR REK RR kk REK RR RR ok ok k REK RR RR I RR RR RR I I k kk okok k ok okok k k End of function R ICU IROIsFallingEdge CK Ck Ck kok kok ok ok RR okok ok kok kok okok okok k kok kok kk k kk k k kok kok kk k kk k k kk k k kk k kk k k kk k kk RE RR REK RR RR REK RE BR ok k kok k oko kok k kk ko kk k k k k k REK RR kok kok k k k kok kok kok RR k k k kok kok k k k k
54. ntended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury artificial life support devices or systems surgical implantations etc or may cause serious property damages nuclear reactor control systems military equipment etc You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application for which it is not intended Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics 6 You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges 7 Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions Further Renesas Electronics
55. nterrupt Controller Unit o Duces Oscillation stop detection function Disabled E B DMA Controller E amp Data Transfer Controller lo B X Event Link Controller a M VO Ports Main clock oscillator H a Multi Function Timer Pulse Uni 1 w Port Output Enable 3 6 17 General PWM Timer x 100 lt 16 Bit Timer Pulse Unit an H a Programmable Pulse Generator H B Bit Timer H a Compare Match Timer H a Compare Match Timer W amp Realtime Clock Ri Watchdog Timer amp Independent Watchdog Timer Sub clock oscillator and RTC RTCSCLK setting E Operation Drive capacity for low CL 32 768 225273 pele Serial Communications Interfac pele Serial Communications Interfac High speed clock oscillator HOCO setting m DC Bus Interface 7 Operation Serial Peripheral Interface 16 CRC Calculator fy 12 Bit A D Converter Low speed clock oscillator LOCO setting 12 Bit D A Converter V Operation li Data Operation Circuit E aa v esd Code Preview Output ax CC RX Build Tool Information M0200002 The following plug ins are not enabled a M RX Simulator Debug Tool E LI File Code Generator Plug in U Debug Console Plug in Pin Configurator Plug in Program Analyzer Plug in IronPython Console Plug in at All Messages v m 162 Output l Error List Fi Fa F3 FA es FE F1 Fa es Fa Fn He gi DISCONNECT O OO O mp ES TT O EE Figure 4 1 Initial View Code Generator provid
56. ok kok kok kok kk k kok kok kok k kk ER ke k k k Function Name R ICU IROSetFallingEdge Description This function sets clears the falling edge trigger for the specified ICU_IRQ Arguments urnto t irg no Y uint8 t set f edge 1 if setting falling edge triggered 0 if clearing Return Value None CK Ck Ck Ck kok kok ok ok kk okok ok kok kok okok kk ke kk RR kk okok okok ke kok RR kk RR RR ke kk k kk k kk RR kk k ke RR REK ke k EX k ke ke ke ke ke RR void R ICU IROSetFallingEdge const uint8 t irg no const uint8 t set f edge if 1 set_f_edge ICU IROCR irg no BYTE 04 ICU IRO EDGE FALLING else ICU IRQCR irq no BYTE amp uint8 t 04 ICU IRO EDGE FALLING BR kok k kok k RR RR RR RR ke kk RR kk REK RR RR RR kk RR RR A k k k k End of function R ICU IROSetFallingEdge kok kok kok kok ok ok kok ko kok kok kok kok k kok kok kok kok k kok kok kok kok kk k kok kok kok k k kk k kk k k kk k kk k k kk k RR RR RR RE BR K K k k IKK RR RARR RR REK kok o RR RR REK RR I KERR I II oko kok k RR RR k k RR ke RR k k k k k k k k k k k k k k k Function Name R ICU IROSetRisingEdge Description This function sets clear the rising edge trigger for the specified ICU IRO Hints t irg no uint8 t set r edge 1 if setting rising edge triggered 0 if clearing Return Value None KERKE k kok kok Ck Ck kk okok ok Ck ok kk okok okok ke kk RR kk RR RR ke kk RR kk RE RR ke kk Ck ko kk k
57. ol Window Help i MODE DO IM 2082 8 ge B CG Tutorial Project ME RSF564MLCxFC Microcontroller gu Code Generator Design Tool m Peripheral Functions df Code Preview bes CC RX Build Tool El RX Simulator Debug Tool i Pall cu R20UT2930EG0100 Rev 1 00 Jul 21 2014 ENES 4 Generate File Mode Output folder File generation control Register files Report type 4 Product Information Release date Version Page 10 of 50 RSK RX64M 4 Code Generation Using the CubeSuite plug in 4 Code Generation Using the CubeSuite plug in 4 1 Introduction Code Generator is a Windows GUI tool for generating template C source code and project settings for the RX64M When using Code Generator the user is able to configure various MCU features and operating parameters using intuitive GUI controls thereby bypassing the need in most cases to refer to sections of the Hardware Manual Once the user has configured the project the Generate Code function is used to generate three code modules for each specific MCU feature selected These code modules are name r_cg_xxx h r_cg_xxx c and r_cg_xxx_user c where xxx is a three letter acronym for the relevant MCU feature for example adc Within these code modules the user is then free to add custom code to meet their specific requirement Custom code should be added whenever possible in between the following com
58. 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 systems manufactured by you 8 Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations 9 Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations You should not use Renesas Electronics products or technology described in this document for any purpose relating to m
59. rt Portc PortD Pon Por PortG Ports P40 Unused Ond Om DO Pulp CMOS output I Output 1 P41 Unused On Out Pulup CMOS output O Output 1 1 P42 Unused In Out C Pull up CMOS output y C Output 1 P43 Unused n Out Pull up CMOS output M Output 1 P44 Unused O n Out Pulup CMOS output P45 Unused On Ou Pulup CMOS output y Output 1 P46 Unused In Ou I Pullup CMOS output Output 1 P47 Unused In Out O Pull up CMOS output v E Output 1 I n Figure 4 15 VO ports Port4 Peripheral function configuration is now complete Save the project using the File gt Save Project menu item then click Generate Code The Output pane should report The operation of generating file was successful as shown Figure 4 16 below R20UT2930EG0100 Rev 1 00 RENESAS Page 23 of 50 Jul 21 2014 RSK RX64M 4 Code Generation Using the CubeSuite plug in Output M0409002 The generating source folder is C Workspace CG_Tutorial M0409001 The following files were generated d M0409000 cg srcXr cg main c was generated l M0409000 cg srcXr cg dbsct c was generated d M0409000 cg srcXr cg intprg c was generated d M0409000 cg srcXr cg resetprg c was generated d M0409000 cg srcXr cg sbrk c was generated d M0409000 cg srcXr cg vecttbl c was generated d M0409000 cg srcXr cg sbrk h was generated d M0409000 cg srcXr cg stacksct h was generated d
60. tart user code Do not edit comment generated here while 1U End user code Do not edit comment generated here 5 3 1 SPI Code The Okaya LCD display is driven by the SPI Master that was configured using Code Generator in 4 3 4 In the Cubesuite Project Tree open the file r_cg_sci h by double clicking on it Insert the following code in the user code area at the end of the file Start user code for function Do not edit comment generated here End user code Do not edit comment generated here Now open the r_cg_sci_user c file and insert the following code in the user area for global Start user code for global Do not edit comment generated here End user code Do not edit comment generated here Insert the following code in the transmitend call back function for SCI6 static void r_sci6_callback_transmitend void Start user code Do not edit comment generated here End user code Do not edit comment generated here Now insert the following function in the user code area at the end of the file ORK k k k k k k KKK okok okok okok okok ok ok ok ok okok okok kk kk kkk kk kkk kk kkk kk kk kkk okok kk kkk kk kk k Function Name R SCI6 SPIMasterTransmit Description This function sends SPI6 data to slave device Arguments i ta 0 P transfer buffer pointer tx num ki buffer size Return Value status R20UT2930EG0100 Rev 1 00 RENESAS
61. ted here Open the file r_cg_cmt_user c and insert the following code in the user area for global at the beginning of the file Start user code for global Do not edit comment generated here End user code Do not edit comment generated here Scroll down to the r cmt cmiO interrupt function and insert the following line in the user code area static void r cmt cmi0 interrupt void Start user code Do not edit comment generated here End user code Do not edit comment generated here R20UT2930EG0100 Rev 1 00 RENESAS Page 31 of 50 Jul 21 2014 RSK RX64M 5 Completing the Tutorial Project Then insert the following function in the user code area at the end of the file DE e e e e e e e e e e e e III kokao IG OOOO Function Name R_CMT_MsDelay Description Uses CMTO to wait for a specified number of milliseconds Arguments uintl16 t millisecs number of milliseconds to wait Return Value None vk ok okok kok kok RR kok RR RR okok ok RR kok okok okok k kok kok kok ok kk k okok okok okokok okok okok k kk k k kk k k kk k kk RAR RAR RARA RARAS void R CMT MsDelay const uintl6 t millisec uint16_t ms_count 0 do R_CMTO_Start while FALSE one_ms_delay_complete Wait R CMTO Stop one ms delay complete FALSE ms_count while ms_count lt millisec KKK kok k k k k k k k EK k k k A RR k k RR k k kok kk k EK ER kk k kok kk k EK RR kk k kk kk
62. ting v Group BLO Priority Level 15 highest Group BL1 setting Group BL1 Priori Level 15 highest Group ALO setting Group ALO ric Level 15 highest Group AL1 setting Group AL1 y Level 15 highest Figure 4 4 Group Interrupt Functions tab 4 3 2 Compare Match Timer Navigate to the Compare Match Timer node in Code Generator CMTO will be used as an interval timer for generation of accurate delays CMT1 and CMT2 will be used as timers in de bouncing of switch interrupts In the CMTO sub tab configure CMTO as shown in Figure 4 5 This timer is configured to generate a High priority interrupt every 1ms We will use this interrupt later in the tutorial to provide an API for generating high accuracy delays required in our application MX kia E Property 3 Peripheral Functions g El Generate Code LI domo d AAS POCO SASSO GIP RS FBT CMTO CMT1 CMT2 CMT3 E Compare match timer operation setting Unused Used A ii m Count clock setting PCLK 8 PCLK 32 PCLK 128 PCLK 512 Interval value setting Interval value 1 ms v Actual value 1 Interrupt setting V Enable compare match interrupt CMIO Priority Level 10 Figure 4 5 CMTO tab Navigate to the CMT1 sub tab and configure CMT1 as shown in Figure 4 6 This timer is configured to generate a High priority interrupt after 20
63. ts Macro definition Invalidates the predefined macro 4 Optimization Optimization type 4 Section Section start address No optimize NOOPtimize RXv2 architecture isa rxw2 Yes fpu Little endian data endian little round to nearest round nearest Handles as zeros denormalize off Handles in single precision dbl size 4 No Handles as unsigned char unsigned char Handles as unsigned unsigned bitfield No Allocates from right bit_order right No unpack No noexception Nol rtti off None fint_register 0 Compiles within 24 bits branch 24 None None 00000000 None C99 lang c99 C C89 lang c Include files at the head of coi Macro definition O B 1R 1B 2R 2B R 5U 51 04 PResetPRG OFFFFBOOO C 1 C The specified section that outputs The specified section that outputs externally defined symbols to tF Section alignment 4 ROM to RAM mapped section 0 D R 1 D 1 R 1 2 D 2 R 2 RTENESAS Section alignment 0 ROM to RAM mapped section 3 I Page 26 of 50 RSK RX64M e These settings are easily added by clicking the button and pasting the following text into the dialog D R D 1 R 1 D 2 R 2 e This ensures that the linker assigns RAM rather than ROM addresses to C variables e From the Build menu select Build Mode Settings Click Duplicate and in the resulting Character String Input dialog enter Debug for the name of the
64. u Tel el 7th Tel Uni Tel el el 80 Tel e 41 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 1101 Nicholson Road Newmarket Ontario L3Y 9C3 Canada 1 905 898 5441 Fax 1 905 898 3220 Renesas Electronics Europe Limited es Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K 44 1628 651 700 Fax 44 1628 651 804 Renesas Electronics Europe GmbH Arcadiastrasse 10 40472 D sseldorf Germany 49 211 65030 Fax 49 211 6503 1327 Renesas Electronics China Co Ltd Floor Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100083 P R China 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd t 301 Tower A Central Towers 555 LanGao Rd Putuo District Shanghai China 86 21 2226 0888 Fax 86 21 2226 0999 Renesas Electronics Hong Kong Limited Unit 1601 1613 16 F Tower 2 Grand Century Place 193 Prince Edward Road West Mongkok Kowloon Hong Kong 852 2886 9318 Fax 852 2886 9022 9044 Renesas Electronics Taiwan Co Ltd 3F No 363 Fu Shing North Road Taipei Taiwan 886 2 8175 9600 Fax 886 2 8175 9670 Renesas Electronics Singapore Pte Ltd Bendemeer Road Unit 06 02 Hyflux Innovation Centre Singapore 339949 465 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
65. upt ERI7 TEI7 ERIT priority Group BLO Level 15 highest Callback function setting V Transmission end Y Reception end Reception error R20UT2930EG0100 Rev 1 00 Jul 21 2014 m b Figure 4 12 SCI7 Asynchronous Setting EN ESAS Page 21 of 50 RSK RX64M 4 Code Generation Using the CubeSuite plug in 4 3 5 VO Ports Referring to the RSK schematic LEDO is connected to P03 LED1 is connected to P05 LED2 is connected to P26 and LED3 is connected to P27 Navigate to the I O Ports tab in Code Generator and configure these four I O lines as shown in Figure 4 13 and Figure 4 14 below Ensure that the Output 1 tick box is checked This ensures that the code is generated to set LEDs initially off F9 Property 23 Peripheral Functions x fe Generate Code EE RAS ERU OR Outpt 1 C Hghdive output P01 a I 9 Unused O In Out Pull up CMOS output v Output High drive output Unused ond Oost Pul up CMOS output y C Output 1 High drive output P03 Unused O in Out up CMOS output v V Output 1 High drive output P05 Unused O In Out Pull up CMOS output v V Output 1 High drive output P07 Unsed n OO Pulup CMOS output Output 1 m D E Figure 4 13 VO ports Porto ES Property Sil Peripheral Functions he X fe Generate Code E el G8 Peripheral Functions id ze ize de k
66. ze O Outputs additional information for inter module optimization Optimization type 1 optimize 1 Outputs a source list file 2 optimize 2 4 Frequently Used ptions for Assemble Max optimize max e All of the sample code projects CCK Property a e El contained in this RSK are lt BuldMode Tum configured with three Build modes CPU DefaultBuild Debug and PIC PID 4 Output File Type andPath Release Release is created in Output fle type Execute Module Load Module File the same way as above by Intermediate file output folder BuildModeN ame d li ti D f It B il d 4 Frequently Used Options for Compie up icaung etau una Additional include paths Additional include paths 2 Release build mode leaves code System include paths System include paths 0 i Macro definition Macro definition 0 optimisation turned on and Dutputs de malo i Outputs debugging information No nodebug v removes debug information from Optimization level Yesl debug Outputs additional information for inter module optimization the output file nes i 1 Outputs a source list file No nolistfile To remove debug information from 4 Frequently Used Options for Assemble the Release build mode in the Additional include paths Additional include paths 0 CC RX Property window select System include paths System include paths 0 i 3 Macro definition Macro definition 0 the Common Options tab

Download Pdf Manuals

image

Related Search

Related Contents

Samsung 400DXN Инструкция по использованию  87-01150-10rB Sysgen SC5500 Tape Controller Interface  Ansmann XPERT800  

Copyright © All rights reserved.
Failed to retrieve file