![]() |
Synergy Software Package User's Manual
|
The Independent Watchdog Timer (IWDT) HAL module provides a high-level API for watchdog timer applications and uses the IWDT peripheral on the Synergy MCU. A user-defined callback can be created to respond to event notifications.
The IWDT HAL module supports the following key features:
The following hardware features are, or are not, supported by SSP for IWDT:
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | Count down | Autostart mode | Reset output | Interrupt request output |
|---|---|---|---|---|
| S124 | ✓ | ✓ | ✓ | ✓ |
| S128 | ✓ | ✓ | ✓ | ✓ |
| S1JA | ✓ | ✓ | ✓ | ✓ |
| S3A1 | ✓ | ✓ | ✓ | ✓ |
| S3A3 | ✓ | ✓ | ✓ | ✓ |
| S3A6 | ✓ | ✓ | ✓ | ✓ |
| S3A7 | ✓ | ✓ | ✓ | ✓ |
| S5D3 | ✓ | ✓ | ✓ | ✓ |
| S5D5 | ✓ | ✓ | ✓ | ✓ |
| S5D9 | ✓ | ✓ | ✓ | ✓ |
| S7G2 | ✓ | ✓ | ✓ | ✓ |
| MCU Group | Sleep mode count stop control output | Event link function through ELC HAL driver | Window function | Conditions for stopping the Counter – reset/underflow- refresh error | Refresh error and under flow error detect | Reading the counter value |
|---|---|---|---|---|---|---|
| S124 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S128 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S1JA | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S3A1 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S3A3 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S3A6 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S3A7 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S5D3 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S5D5 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S5D9 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| S7G2 | ⌧ | ⌧ | ✓ | ✓ | ✓ | ✓ |
| MCU Group | Selecting the clock frequency division ratio after a reset | Selecting the timeout period of the independent watchdog timer |
|---|---|---|
| S124 | ⌧ | ✓ Set by the OFS registers in the BSP |
| S128 | ⌧ | ✓ Set by the OFS registers in the BSP |
| S1JA | ⌧ | ✓ Set by the OFS registers in the BSP |
| S3A1 | ⌧ | ✓ Set by the OFS registers in the BSP |
| S3A3 | ⌧ | ✓ Set by the OFS registers in the BSP |
| S3A6 | ⌧ | ✓ Set by the OFS registers in the BSP |
| S3A7 | ⌧ | ✓ Set by the OFS registers in the BSP |
| S5D3 | ⌧ | ✓ Set by the OFS registers in the BSP |
| S5D5 | ⌧ | ✓ Set by the OFS registers in the BSP |
| S5D9 | ⌧ | ✓ Set by the OFS registers in the BSP |
| S7G2 | ⌧ | ✓ Set by the OFS registers in the BSP |
The IWDT HAL module defines APIs for open, refresh, read and get status. A complete list of the available APIs, an example API call and a short description of each can be found in the following table. A table of status return values follows the API summary table.
Independent Watchdog Timer HAL Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| cfgGet | g_wdt0.p_api->cfgGet(g_wdt0.p_ctrl, g_wdt0.p_cfg);Initialize the iWDT in register start mode. In auto-start mode with NMI output it registers the NMI callback. |
| open | g_wdt0.p_api->open(g_wdt0.p_ctrl, g_wdt0.p_cfg);Initialize the iWDT in register start mode. In auto-start mode with NMI output it registers the NMI callback. |
| refresh | g_wdt0.p_api->refresh(g_wdt0.p_ctrl);Refresh the watchdog timer. |
| statusGet | g_wdt0.p_api->statusGet( g_wdt0.p_ctrl, &status);Read the status of the iWDT. |
| statusClear | g_wdt0.p_api->statusClear( g_wdt0.p_ctrl, clear);Clear the status flags of the iWDT. |
| counterGet | g_wdt0.p_api->counterGet(g_wdt0.p_ctrl, &counter);Read the current iWDT counter value. |
| tiimeoutGet | g_wdt0.p_api->timeoutGet(g_wdt0.p_ctrl, &timeout);Read the watchdog timeout values. |
| versionGet | g_wdt0.p_api->versionGet(&version);Retrieve the API version using the version pointer. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | Function successfully executed. |
| SSP_ERR_ASSERTION | Null Pointer(s). |
| SSP_ERR_INVALID_ARGUMENT | One or more configuration options is invalid. |
| SSP_ERR_INVALID_MODE | An attempt to open the WDT in register-start mode when the OFS0 register is configured for auto-start mode. Or to open the WDT in auto-start mode when the OSF0 is configured for register start mode. |
| SSP_ERR_ABORTED | Invalid clock divider for this watchdog. |
The IWDT HAL module configures the IWDT Interface. When the IWDT underflows or is refreshed outside of the permitted refresh window, one of the following events can occur:
The following figure shows an example of the operation of the IWDT. When refreshed in the valid refresh period of the counter the timer count value is reset. If the count is allowed to underflow or refresh occurs outside of the valid refresh period, the IWDT resets the device or generates an NMI.
All series of Synergy microcontrollers have an option-setting Memory which can be used to set the operating state of peripherals after a reset. The OFS can be used to set the state of the IWDT, WDT, LVD and CGC HOCO.
The following table details which parameters of the IWDT can be configured by the OFS registers.
| Control | Description |
|---|---|
| IWDT Start Mode Select | Automatically starts the IWDT after a Reset, if enabled. |
| IWDT Timeout Period | Specifies the IWDT timeout (number of clock cycles) 128 cycles 512 cycles 1024 cycles 2048 cycles |
| IWDT-Dedicated Clock Frequency Division Ratio | 1 1/16 1/32 1/64 1/128 1/256 |
| IWDT Window End Position | 25 %50 %75 %100% (no window end position set) |
| IWDT Window Start Position | 25 %50 %75 %100% (no window start position set) |
| IWDT Reset Interrupt Request | The IWDT can either generate an Interrupt Signal or a Reset signal. |
| IWDT Stop Control | The IWDT can continue to count or Stop counting in Low Power Mode. |
The OFS register values are set via the properties dialog of the BSP tab of Synergy Configuration editor as shown in the following figures:
IWDT HAL Module Period Calculation
The IWDT operates from IWDTCLK. Assuming largest parameters for the WDT and an IWDTCLK frequency of 15 kHz, the time from the last refresh to device reset or NMI generation will be just under 35 seconds as detailed below.
IWDTLCK = 15 kHz
Clock division ratio = IWTCLK/256
Timeout period = 2048 cycles
IWDT clock frequency = 15 kHz / 256 = 58.59 Hz
Cycle time = 1 / 58.59 Hz = 17.07 ms
Timeout = 17.07 ms x 2048 cycles = 34.95 seconds
Triggering DMAC/DTC with the IWDT HAL Module
To trigger a transfer of data using the DMAC or DTC peripheral when the watchdog counter underflows or when a refresh is attempted outside of the valid refresh period, configure the DMAC/DTC transfer with activation_source set to ELC_EVENT_IWDT_UNDERFLOW. See the appropriate module guide for additional information.
Triggering ELC Events with the IWDT HAL Module
The IWDT can trigger the start of other peripherals as available with the Event Link Controller (ELC). See the ELC HAL module guide for additional information.
This section describes how to include the Independent Watchdog Timer HAL Module in an application using the SSP configurator.
To add the Independent Watchdog Timer Driver to an application, simply add it to a thread using the stacks selection sequence given in the following table. (The default name for the Independent Watchdog Timer Driver is g_iwdt0. This name can be changed in the associated Properties window.)
Independent Watchdog Timer HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_wdt0 IWDT HAL on r_iwdt | Threads | New Stack> Driver> Monitoring> IWDT HAL on r_iwdt |
When the Independent Watchdog Timer Driver on r_iwdt is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower‑level modules. Any modules needing additional configuration information have the box text highlighted in Red. Modules with a Gray band are individual modules that stand alone. Modules with a Blue band are shared or common; they need only be added once and can be used by multiple stacks. Modules with a Pink band can require the selection of lower-level modules; these are either optional or recommended. (This is indicated in the block with the inclusion of this text.) If the addition of lower-level modules is required, the module description include Add in the text. Clicking on any Pink banded modules brings up the New icon and displays possible choices.
The Independent Watchdog Timer HAL Module must be configured by the user for the desired operation. The available configuration settings and defaults for all the user-accessible properties are given in the properties tab within the SSP configurator and are shown in the following tables for easy reference. Only properties that can be changed without causing conflicts are available for modification. Other properties are locked and not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error-prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP Configurator and are shown in the following tables for easy reference.
Configuration Settings for the Independent Watchdog Timer HAL Module on r_iwdt
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enables or disables the parameter checking. |
| Name | g_wdt0 | Module name. |
| NMI Callback | NULL | Callback. A user callback function can be registered in external_irq_api_t::open. If this callback function is provided, it will be called from the interrupt service routine (ISR) each time the IRQn triggers. Warning: Since the callback is called from an ISR, care should be taken not to use blocking calls or lengthy processing. Spending excessive time in an ISR can affect the responsiveness of the system. |
All series of Synergy microcontrollers have an Option-Setting Memory which can be used to set the operating state of peripherals after a reset. The OFS can be used to set the state of the IWDT, WDT, LVD and CGC HOCO.
Use the ISDE to configure the IWDT interrupts in the same way as configuring the other options for the IWDT module. If the IWDT is configured to generate an NMI interrupt on underflow or invalid refresh the interrupt must be enabled in the BSP.
When the IWDT NMIUNDF N interrupt is enabled in the BSP, the corresponding ISR will be defined. The ISR will call a user callback function if one was registered in the wdt_api_t::open API.
The IWDT has its own dedicated clock operating at a set frequency which cannot be modified.
The IWDT does not require pins for its operation.
The typical steps in using the Independent Watchdog Timer HAL module in an application are:
These common steps are illustrated in a typical operational flow diagram in the following figure: