![]() |
RX Flexible Software Package Documentation
Release v1.0.0
|
|
Functions | |
| fsp_err_t | R_IWDT_Refresh (wdt_ctrl_t *const p_api_ctrl) |
| fsp_err_t | R_IWDT_Open (wdt_ctrl_t *const p_api_ctrl, wdt_cfg_t const *const p_cfg) |
| fsp_err_t | R_IWDT_StatusClear (wdt_ctrl_t *const p_api_ctrl, const wdt_status_t status) |
| fsp_err_t | R_IWDT_StatusGet (wdt_ctrl_t *const p_api_ctrl, wdt_status_t *const p_status) |
| fsp_err_t | R_IWDT_CounterGet (wdt_ctrl_t *const p_api_ctrl, uint32_t *const p_count) |
| fsp_err_t | R_IWDT_TimeoutGet (wdt_ctrl_t *const p_api_ctrl, wdt_timeout_values_t *const p_timeout) |
| fsp_err_t | R_IWDT_CallbackSet (wdt_ctrl_t *const p_ctrl, void(*p_callback)(wdt_callback_args_t *), void *const p_context, wdt_callback_args_t *const p_callback_memory) |
Driver for the IWDT peripheral on RX MCUs. This module implements the WDT Interface.
The independent watchdog timer is used to recover from unexpected errors in an application. The timer must be refreshed periodically in the permitted count window by the application. If the count is allowed to underflow or refresh occurs outside of the valid refresh period, the IWDT resets the device or generates an IRQ.
The IWDT HAL module has the following key features:
RX MCUs have two watchdog peripherals: the watchdog timer (WDT) and the independent watchdog timer (IWDT). When selecting between them, consider these factors:
| WDT | IWDT | |
|---|---|---|
| Start Mode | The WDT can be started from the application (register start mode) or configured by hardware to start automatically (auto start mode). | On most of MCUs, the IWDT can only be configured by hardware to start automatically1. |
| Clock Source | The WDT runs off a peripheral clock. | The IWDT has its own clock source which improves safety. |
The configuration of start mode setting is on the BSP tab. The default setting for the start mode is register start mode.
When using register start mode, no need to update the configuration of start mode on the BSP tab. Configure the independence watchdog timer on the Stacks tab.
| Configuration | Options | Default | Description |
|---|---|---|---|
| Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
| NMI Support | MCU Specific Options | NMI is not supported. | |
| IRQ Support | MCU Specific Options | If enabled, code for IRQ support is included in the build. |
| Configuration | Options | Default | Description |
|---|---|---|---|
| Name | Name must be a valid C symbol | g_wdt0 | Module name. |
| Timeout | MCU Specific Options | Select the independent watchdog timeout in cycles. | |
| Clock Division Ratio | MCU Specific Options | Select the independent watchdog clock divisor. | |
| Window Start Position | MCU Specific Options | Select the allowed independent watchdog refresh start point in %. | |
| Window End Position | MCU Specific Options | Select the allowed independent watchdog refresh end point in %. | |
| Reset Control | MCU Specific Options | Select what happens when the independent watchdog timer expires.(NMI request output is not supported) | |
| Stop Control | MCU Specific Options | Select the independent watchdog state in low power mode. | |
| NMI/IRQ callback | Name must be a valid C symbol | NULL | A user callback function can be provided here. If this callback function is provided, it is called from the interrupt service routine (ISR) when the watchdog triggers. |
| IRQ Priority | MCU Specific Options | Select the IWDT interrupt priority. |
The IWDT clock is based on the IWDTCLK frequency. You can set the IWDTCLK frequency divider using the BSP tab of the RX Configuration editor.
This module does not use I/O pins.
The independent watchdog timer uses the NMI, which is enabled by default. No special configuration is required. When the NMI is triggered, the callback function registered during open is called.
The watchdog timer uses an IRQ, and the interrupt priority level must be configured before use. When the IRQ is triggered, the callback function registered during open is called.
The IWDT operates from IWDTCLK. With a IWDTCLK of 120000 Hz, the maximum time from the last refresh to device reset or IRQ generation will be just below 35 seconds as detailed below.
IWDTCLK = 120000 Hz
Clock division ratio = IWDTCLK / 256
Timeout period = 16384 cycles
WDT clock frequency = 120000 Hz / 256 = 468.75 Hz
Cycle time = 1 / 468.75 Hz = 2.1333 ms
Timeout = 2.1333 ms x 16384 cycles = 34.95 seconds
Developers should be aware of the following limitations when using the IWDT:
This is a basic example of minimal use of the IWDT in an application.
This example demonstrates using a start window and gives an example for refreshing before the counter underflows to prevent reset.
Data Structures | |
| struct | iwdt_instance_ctrl_t |
| struct | iwdt_extended_cfg_t |
| struct iwdt_instance_ctrl_t |
IWDT control block. DO NOT INITIALIZE. Initialization occurs when wdt_api_t::open is called.
Data Fields | |
| uint32_t | wdt_open |
| Indicates whether the open() API has been successfully called. | |
| void * | p_context |
| Placeholder for user data. Passed to the user callback in wdt_callback_args_t. | |
| void(* | p_callback )(wdt_callback_args_t *p_args) |
| Callback provided when a WDT NMI ISR occurs. | |
| struct iwdt_extended_cfg_t |
| fsp_err_t R_IWDT_Refresh | ( | wdt_ctrl_t *const | p_api_ctrl | ) |
Refresh the Independent Watchdog Timer. If the refresh fails due to being performed outside of the permitted refresh period the device will either reset or trigger an NMI/IRQ ISR to run.
Example:
| FSP_SUCCESS | IWDT successfully refreshed. |
| FSP_ERR_ASSERTION | One or more parameters are NULL pointers. |
| FSP_ERR_NOT_OPEN | The driver has not been opened. Perform R_IWDT_Open() first. |
| fsp_err_t R_IWDT_Open | ( | wdt_ctrl_t *const | p_api_ctrl, |
| wdt_cfg_t const *const | p_cfg | ||
| ) |
Register the IWDT NMI callback.
Example:
| FSP_SUCCESS | IWDT successfully configured. |
| FSP_ERR_ASSERTION | Null Pointer. |
| FSP_ERR_NOT_ENABLED | An attempt to open the IWDT when the OFS0 register is not configured for auto-start mode. |
| FSP_ERR_ALREADY_OPEN | Module is already open. This module can only be opened once. |
| fsp_err_t R_IWDT_StatusClear | ( | wdt_ctrl_t *const | p_api_ctrl, |
| const wdt_status_t | status | ||
| ) |
Clear the IWDT status and error flags. Implements wdt_api_t::statusClear.
| FSP_SUCCESS | IWDT flag(s) successfully cleared. |
| FSP_ERR_ASSERTION | Null pointer as a parameter. |
| FSP_ERR_NOT_OPEN | The driver has not been opened. Perform R_IWDT_Open() first. |
| FSP_ERR_UNSUPPORTED | This function is only valid if the IWDT generates an NMI/IRQ when an error occurs. |
| fsp_err_t R_IWDT_StatusGet | ( | wdt_ctrl_t *const | p_api_ctrl, |
| wdt_status_t *const | p_status | ||
| ) |
Read the IWDT status flags.
Indicates both status and error conditions.
| FSP_SUCCESS | IWDT status successfully read. |
| FSP_ERR_ASSERTION | Null pointer as a parameter. |
| FSP_ERR_NOT_OPEN | The driver has not been opened. Perform R_IWDT_Open() first. |
| FSP_ERR_UNSUPPORTED | This function is only valid if the IWDT generates an NMI when an error occurs. |
| fsp_err_t R_IWDT_CounterGet | ( | wdt_ctrl_t *const | p_api_ctrl, |
| uint32_t *const | p_count | ||
| ) |
Read the current count value of the IWDT. Implements wdt_api_t::counterGet.
Example:
| FSP_SUCCESS | IWDT current count successfully read. |
| FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
| FSP_ERR_NOT_OPEN | The driver has not been opened. Perform R_IWDT_Open() first. |
| fsp_err_t R_IWDT_TimeoutGet | ( | wdt_ctrl_t *const | p_api_ctrl, |
| wdt_timeout_values_t *const | p_timeout | ||
| ) |
Read timeout information for the watchdog timer. Implements wdt_api_t::timeoutGet.
| FSP_SUCCESS | IWDT timeout information retrieved successfully. |
| FSP_ERR_ASSERTION | One or more parameters are NULL pointers. |
| FSP_ERR_NOT_OPEN | The driver has not been opened. Perform R_IWDT_Open() first. |
| fsp_err_t R_IWDT_CallbackSet | ( | wdt_ctrl_t *const | p_ctrl, |
| void(*)(wdt_callback_args_t *) | p_callback, | ||
| void *const | p_context, | ||
| wdt_callback_args_t *const | p_callback_memory | ||
| ) |
Updates the user callback and has option of providing memory for callback structure. Implements wdt_api_t::callbackSet
| FSP_SUCCESS | Callback updated successfully. |
| FSP_ERR_ASSERTION | A required pointer is NULL. |
| FSP_ERR_NOT_OPEN | The control block has not been opened. |