Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using PDG with e2studio: Example

Similar presentations


Presentation on theme: "Using PDG with e2studio: Example"— Presentation transcript:

1 Using PDG with e2studio: Example
Here is a simple example project using Renesas Peripheral Driver Generator (PDG) for RX and the e2studio IDE to get an LED to flash on a Renesas Starter Kit+ for RX63N Configure I/O Port 10, connected to LED2 on the RSK+, as a general purpose Output pin. From the RSK+ schematic page 2: Use Timer 0 to generate periodic interrupts to turn the LED on and off © 2010 Renesas Electronics Europe. All rights reserved.

2 LED Flash Example The LED will turn on when the output from port 10 is 0, and will turn off when it is 1. © 2010 Renesas Electronics Europe. All rights reserved.

3 e2studio Project Start Renesas e2studio and specify a new workspace
e.g. C:\Workspace\RX63N Create a new project: e.g. RX63N_LED_Flash We will be using E1 for hardware debug and the default of Little-endian data Select the correct device for your hardware target e.g. for RSK+ for RX63N select part number R5F563NBDxFC Click ‘Finish’ to run create the project © 2010 Renesas Electronics Europe. All rights reserved.

4 PDG Project Now start PDG and create a new project
Start > All programs > Renesas > Peripheral Driver Generator 2 Click on File -> New Project Name the project ‘PDG_Files’ and locate it in the folder for the e2studio project you just created: e.g. C:\WorkSpace\RSK63N\RX63N_LED_Flash Ensure you have the right device part number, (which determines package and ROM/RAM capacity) selected for your target hardware e.g. For RSK+ for RX63N select part number R5F563NBDDFC (176 LQFP, 1MB Flash) Click ‘OK’ and after a few moments the PDG project editor will be displayed.. © 2010 Renesas Electronics Europe. All rights reserved.

5 Configure the PDG project – System clocks
The clocking System window opens The error icons are initially displayed to show that configuration is necessary Move the mouse over the error icon to see a tooltip © 2010 Renesas Electronics Europe. All rights reserved.

6 Configure the PDG project – System clocks(2)
Set up the Main clock (EXTAL input) frequency. The RSK+ for RX63N includes a 12MHz external crystal. Type ’12’ into the dialog box then scroll down and add the internal clock frequencies: In this example we will not use the PLL, which can generate an instruction clock up to the maximum (100MHz). Set the Instruction, Peripheral and Flash clocks to 3MHz: © 2010 Renesas Electronics Europe. All rights reserved.

7 Configure the PDG project – Ports
Set up the I/O pin connected to the LED2 Select the I/O tab Select Port 1 and tick P10 ‘Used as an I/O port’ Select ‘Direction : Output’, CMOS output, High-drive output © 2010 Renesas Electronics Europe. All rights reserved.

8 Configure the PDG project - TMR
Set up the TMR timer to generate periodic interrupts: Select the ‘TMR’ tab Click on ‘Unit 0’ and select ‘Mode: 16-bit timer mode’ Tick ‘Use this channel’ box Select ‘Count source: Internal clock (PCLK/8192)’ Select ‘Counter clearing source: Compare match B’ Click on ‘Timer operating period’ field and input 1000msec Choose a ‘Duty cycle’ of 50% The values to be used for the Compare match A and Compare match B register settings are automatically calculated and displayed © 2010 Renesas Electronics Europe. All rights reserved.

9 Configure the PDG project - TMR (2)
Configure the TMR timer to generate interrupts at both Compare match events (A and B): Note: The ‘Interrupt notification function names’ can be changed to the users preference in this setting dialogue, if desired Check 'compare match A interrupt'. Notification function is 'Tmr0CmAIntFunc' Check 'compare match B interrupt'. 'Tmr0CmBIntFunc © 2010 Renesas Electronics Europe. All rights reserved.

10 Configure the PDG project – Generate files
We have setup our system. Let’s now get the PDG to generate the peripheral driver code that we need to start coding. Click on Tool -> Generate Source Files or click on the icon in the toolbar When asked to Save, click OK And finally click OK © 2010 Renesas Electronics Europe. All rights reserved.

11 Finding the PDG files in e2studio
Go back into e2studio, which you should still have open in the background Right-click on the project name in the Project Explorer view and select ‘Refresh’ (or hit F5) You will now see the folder ‘PDG_Files’ appear in your project with the source files generated by PDG © 2012 Renesas Electronics Europe. All rights reserved.

12 Modifying the e2studio project
Copy the library file manually from PDG installation to your project: In the installation directory of PDG (e.g. C:\Renesas\PDG2), there is a folder 'lib' for library files and then sub-folders for each processor group. The library files have different versions for each package size and for little and big endian. Copy the library file for your configuration to the PDG_files folder in the e2 studio project: e.g. Copy ‘RX63N_library_176_little.lib’ to C:\WorkSpace\RSK63N\RX63N_LED_Flash\PDG_Files Exclude some files in the 'src' directory of the e2studio project from build: Select files in 'Project Explorer' window: interrupt_handlers.c vector_table.c Right mouse button click and select 'Exclude from Build' Select all configurations and click ‘OK ‘ Modify the project settings: Mark the project in 'Project Explorer' and go to 'Project' > 'Renesas Tool Settings' or click on the toolbar In ‘Settings’ , ‘Compiler’ > ‘Source’ add a new include file directory: In ‘Include file directories’ select the icon then click ‘Workspace’ Select your PDG file directory: The entry should be like this: ${workspace_loc:/${ProjName}/PDG_files} Repeat for the 'i_src' directory: ${workspace_loc:/${ProjName}/PDG_files/i_src} Change the precision for ‘double’ variables: PDG and RPDL require double variables set to 'Double precision' (64-bit). The default setting for CCRX is 'Single precision' change this in the compiler settings in group 'CPU' > 'Advanced'. © 2012 Renesas Electronics Europe. All rights reserved.

13 Modifying the e2studio project (2)
In ‘Settings’ > 'Linker' > 'Input' add the PDG library file: Click the icon and click 'Workspace‘, select your PDG file directory then select the library file e.g. ${workspace_loc:/${ProjName}/PDG_Files/RX63N_library_176_little.lib} In ‘Settings’ > 'Linker' > 'Sections‘ modify the Linker settings: Delete section 'PIntPRG‘, select it under ‘Section Name’ and click ‘Remove section’. This is created by e2studio Project Generator and is not required as PDG has defined the interrupts Change the start address for section 'FIXEDVECT‘ from 0xFFFFFF80 to 0xFFFFFFD0. You can modify the address directly in the Section viewer window Modify file 'reset_program.c‘ in 'src' folder This file is created by e2studio and provides the start-up code and low level initialization after RESET. But the name of the reset function is different from the reset vector generated by PDG. Change the label ‘PowerON_Reset’ to ‘PowerON_Reset_PC’ each time it is used in this file, once for the function prototype at the beginning of the file, once for the #pragma entry definition, and once for the function definition. © 2012 Renesas Electronics Europe. All rights reserved.

14 Edit ‘main’ function Double click on ‘RX63N_LED_Flash.c’ file in the ‘src’ folder to open the file. Edit the ‘main’ function to include the PDG header files: #include "R_PG_PDG_Files.h" #include "R_PG_RPDL_headers.h“ Call the initialisation functions for the System Clocks, I/O Port pin and Timer – see image: Add in the interrupt functions for the TMR interrupts and add the calls to the functions to turn on and off the LED on Port P10 Now build the project by selecting ‘Project’ > ‘Build All’ © 2012 Renesas Electronics Europe. All rights reserved.

15 Debugging the project When we created the e2studio project, we automatically generated a Debug Configuration for the E1 debugger You can check this configuration by selecting ‘Run’ > ‘Debug configurations…’ Make sure your E1 is connected to a USB port on your PC and to the target hardware (e.g. RSK+) via the 16-way ribbon cable Start the E1 debugger by clicking ‘Debug’ The e2studio ‘console’ view will show the connection dialogue and if successful a window will appear prompting you to open the Debug Perspective Click on the icon. The Program Counter indicator will stop on ‘main’. Click on the icon again, and the code should run and LED2 should flash.. © 2012 Renesas Electronics Europe. All rights reserved.

16 Modifying the PDG configuration
Now let’s modify the system configuration within PDG and observe the changes within our e2studio project Switch to PDG and in the TMR tab change the ‘Timer operating period’ to 200msec Click on the icon to generate the source files again Switch back into e2studio and rebuild the project by clicking on the icon When the project is reloaded on the target, run the code again and observe the increased LED2 flashing frequency. © 2012 Renesas Electronics Europe. All rights reserved.

17 © 2010 Renesas Electronics Europe. All rights reserved.


Download ppt "Using PDG with e2studio: Example"

Similar presentations


Ads by Google