![]() |
Synergy Software Package User's Manual
|
This application uses the WDT Interface implemented by the WDT HAL Driver WDT. This document describes how to use the ISDE and SSP to create an application for the Synergy MCU Watchdog Timer (WDT) peripheral. This application makes use of the following SSP modules:
The Synergy Software Package (SSP) from Renesas provides a complete driver library for developing Synergy applications. The SSP provides Hardware Abstraction Layer (HAL) drivers, Board Support Package (BSP) drivers and higher level Framework applications for the developer to use to create applications. The SSP is integrated into the Renesas e2 studio Integrated Solution Development Environment (ISDE) based on eclipse providing build (editor, compiler and linker) and debug phases with an extended GNU Debug (GDB) interface.
The flowchart for the WDT application is shown below.
These are the main parts of the WDT application:
Start the ISDE and choose a workspace folder in the Workspace Launcher. Configure a new Synergy project as follows.
This application runs on the Synergy S7G2 based DK-S7G2 board. So, for the Board select S7G2 DK.
This will automatically populate the Device drop-down with the correct device used on this board. Select the Toolchain version. Select J-Link ARM as the Debugger. No RTOS is being used in this application but it can be left at the default. Click Next to configure the project.
The project template is now selected. As no RTOS is required select BSP.
The ISDE creates the project and opens the Project Explorer and Project Configuration Settings views with the Summary page showing a summary of the project configuration.
The e2 studio ISDE simplifies and accelerates the project configuration process by providing a GUI interface for selecting the options to configure the project.
The ISDE offers a selection of perspectives presenting different windows to the user depending on the operation in progress. The default perspectives are C/C++ , Synergy Configuration and Debug. The perspective can be changed by selecting a new one from the buttons at the top right of the ISDE.
The C/C++ perspective provides a layout selected for code editing. The Synergy Configuration perspective provides elements for configuring a Synergy project, and the Debug perspective provides a view suited for debugging.
The BSP tab allows the Board Support Package (BSP) options to be modified from their defaults. For this particular WDT project no changes are required. However, if you want to use the WDT in auto-start mode, you can configure the settings of the OFS0 (Option Function Select Register 0) register in the BSP tab. See the Synergy Hardware User’s Manual for details on the WDT autostart mode.
The clocks tab presents a graphical view of the clock tree of the device. Using the drop down boxes in the GUI enables configuration of the various clocks. The WDT uses PCLCKB. The default output frequency for this clock is 60 MHz. Ensure this clock is outputting this value.
The Pins tab provides a graphical tool for configuring the functionality of the pins of the device. For the WDT project no pin configuration is required. Although the project uses two LEDs connected to pins on the device, these pins are pre-configured as output GPIO pins by the BSP.
You can add any driver to the project using the Threads tab. The HAL drivers for the Clock Generation Circuit, the Event Link Controller, and the IO port pins are added automatically by the ISDE when the project is configured. The WDT application uses no ThreadX Resources, so you only need to add the HAL WDT driver.
The HAL/Common Stacks panel and is populated with the modules preselected by the ISDE.
Change parameter Start Watchdog After Configuration from True to False. The other parameters can be left with their default values. Setting Start Watchdog After Configuration to False instructs the WDT driver (via its open API call) to configure the WDT but not to start it. It will be started later by refreshing it.
With PCLKB running at 60 MHz the WDT will reset the device 2.23 seconds after the last refresh.
WDT clock = 60 MHz / 8192 = 7.32 kHz
Cycle time = 1 / 7.324 kHz = 136.53 us
Timeout = 136.53 us x 16384 = 2.23 seconds
Save the Project Configuration file and click the Generate Project Content button in the top right corner of the Project Configuration pane.
The ISDE generates the project files.
The components tab is included for reference to see which modules are included in the project. Modules are selected automatically in the Components view when after they are added in the Threads Tab.
For the WDT project ensure that the following modules are selected:
Pressing the Generate Project Content button performs the following tasks.
The above files are the standard files for the WDT HAL module. They contain no specific project contents. They are the driver files for the WDT. Further information on the contents of these files can be found in the documentation for the WDT HAL module.
Configuration information for the WDT HAL module in the WDT project is found in:
The above file’s contents are based upon the Common settings in the g_wdt Watchdog Driver on WDT Properties pane.
r_ioport folder is not created at ssp/src/driver as this module is required by the BSP and so already exists. It is included in the WDT project in order to include the correct header file in src/synergy_gen/hal_data.h – see later in this document for further details. For the same reason the other IOPORT header files – synergy/ssp/inc/api/r_ioport_api.h and synergy/ssp/inc/instances/r_ioport.h are not created as they already exist.
In addition to generating the HAL driver files for the WDT and IOPORT files the ISDE also generates files containing configuration data for the WDT and a file where user code can safely be added. These files are shown below.
The contents of hal_data.h are shown below.
hal_data.h contains the header files required by the ISDE generated project. In addition this file includes external references to the g_wdt instance structure which contains pointers to the configuration, control, api structures used for WDT HAL driver.
The contents of hal_data.c are shown below.
hal_data.c contains g_wdt_ctrl which is the control structure for this instance of the WDT HAL driver. This structure should not be initialised as this is done by the driver when it is opened.
The contents of g_wdt_cfg are populated in this file using the g_wdt Watchdog Driver on WDT Properties pane in the ISDE Project Configuration HAL tab. If the contents of this structure do not reflect the settings made in the ISDE, ensure the Project Configuration settings are saved in the ISDE before pressing the Generate Project Content button.
Contains main() called by the BSP start-up code. main() calls hal_entry() which contains user developed code (see next file). Here are the contents of main.c.
This file contains the function hal_entry() called from main(). User developed code should be placed in this file and function.
For the WDT project edit the contents of this file to contain the code below. This code implements the flowchart in overview section of this document.
The WDT HAL driver is called through the interface g_wdt_on_wdt defined in r_wdt.h. The WDT HAL driver is opened through the open API call using the instance defined in r_wdt_api.h:
The first passed parameter is the pointer to the control structure g_wdt_ctrl instantiated in hal_data.c. The second parameter is the pointer to the configuration data g_wdt_cfg instantiated in the same hal_data.c file.
The WDT is started and refreshed through the API call:
Again the first (and only in this case) parameter passed to this API is the pointer to the control structure of this instance of the driver.
Build the project in the ISDE Build > Build Project. The project should build without errors.
To debug the project
The red LED should start flashing. After 30 flashes the green LED will start flashing and the red LED will stop flashing.
While the green LED is flashing the WDT will underflow and reset the device resulting in the red LED to flash again as the sequence repeats. However, this sequence does not occur when using the debugger because the WDT does not run when connected to the debugger.