![]() |
RX Flexible Software Package Documentation
Release v1.0.0
|
|
Functions | |
| fsp_err_t | R_WDT_Refresh (wdt_ctrl_t *const p_ctrl) |
| fsp_err_t | R_WDT_Open (wdt_ctrl_t *const p_ctrl, wdt_cfg_t const *const p_cfg) |
| fsp_err_t | R_WDT_StatusClear (wdt_ctrl_t *const p_ctrl, const wdt_status_t status) |
| fsp_err_t | R_WDT_StatusGet (wdt_ctrl_t *const p_ctrl, wdt_status_t *const p_status) |
| fsp_err_t | R_WDT_CounterGet (wdt_ctrl_t *const p_ctrl, uint32_t *const p_count) |
| fsp_err_t | R_WDT_TimeoutGet (wdt_ctrl_t *const p_ctrl, wdt_timeout_values_t *const p_timeout) |
| fsp_err_t | R_WDT_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 WDT peripheral on RX MCUs. This module implements the WDT Interface.
The watchdog timer is used to recover from unexpected errors in an application. The watchdog 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 WDT resets the device or generates an IRQ.
The WDT 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). | The IWDT can only be configured by hardware to start automatically. |
| 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 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 | Disabled | Disabled | NMI is not supported. |
| IRQ Support |
| Disabled | 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 |
| 16,384 Cycles | Select the watchdog timeout in cycles. |
| Clock Division Ratio |
| PCLK/8192 | Select the watchdog clock divisor. |
| Window Start Position |
| 100 (Window Position Not Specified) | Select the allowed watchdog refresh start point in %. |
| Window End Position |
| 0 (Window Position Not Specified) | Select the allowed watchdog refresh end point in %. |
| Reset Control |
| Reset Output | Select what happens when the watchdog timer expires.(NMI request output is not supported) |
| Stop Control | MCU Specific Options | Select the watchdog state in low power mode. | |
| NMI/IRQ Callback | Name must be a valid C symbol | NULL | A user callback function must be provided if the WDT is configured to generate an NMI or IRQ when the timer underflows or a refresh error occurs. If this callback function is provided, it will be called from the NMI/IRQ handler each time the watchdog triggers. |
| IRQ Priority | MCU Specific Options | Select the WDT interrupt priority. |
The WDT clock is based on the PCLKB frequency. You can set the PCLKB frequency using the Clocks tab of the RX Configuration editor or by using the CGC Interface at run-time. The maximum timeout period with PCLKB running at 60 MHz is approximately 2.2 seconds.
This module does not use I/O pins.
The 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 WDT operates from PCLKB. With a PCLKB of 60 MHz, the maximum time from the last refresh to device reset or IRQ generation will be just over 2.2 seconds as detailed below.
PLCKB = 60 MHz
Clock division ratio = PCLKB / 8192
Timeout period = 16384 cycles
WDT clock frequency = 60 MHz / 8192 = 7.324 kHz
Cycle time = 1 / 7.324 kHz = 136.53 us
Timeout = 136.53 us x 16384 cycles = 2.23 seconds
Developers should be aware of the following limitations when using the WDT:
This is a basic example of minimal use of the WDT in an application.
This example demonstrates using a start window for refreshing before the counter underflows to prevent reset.
Data Structures | |
| struct | wdt_instance_ctrl_t |
| struct | wdt_extended_cfg_t |
| struct wdt_instance_ctrl_t |
WDT private control block. DO NOT MODIFY. Initialization occurs when R_WDT_Open() is called.
| struct wdt_extended_cfg_t |
| fsp_err_t R_WDT_Refresh | ( | wdt_ctrl_t *const | p_ctrl | ) |
Refresh the watchdog timer. Implements wdt_api_t::refresh.
In addition to refreshing the watchdog counter this function can be used to start the counter in register start mode.
Example:
| FSP_SUCCESS | WDT successfully refreshed. |
| FSP_ERR_ASSERTION | p_ctrl is NULL. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| fsp_err_t R_WDT_Open | ( | wdt_ctrl_t *const | p_ctrl, |
| wdt_cfg_t const *const | p_cfg | ||
| ) |
Configure the WDT in register start mode. In auto-start_mode the NMI/IRQ callback can be registered. Implements wdt_api_t::open.
This function should only be called once as WDT configuration registers can only be written to once so subsequent calls will have no effect.
Example:
| FSP_SUCCESS | WDT successfully configured. |
| FSP_ERR_ASSERTION | Null pointer, or one or more configuration options is invalid. |
| FSP_ERR_ALREADY_OPEN | Module is already open. This module can only be opened once. |
| fsp_err_t R_WDT_StatusClear | ( | wdt_ctrl_t *const | p_ctrl, |
| const wdt_status_t | status | ||
| ) |
Clear the WDT status and error flags. Implements wdt_api_t::statusClear.
| FSP_SUCCESS | WDT flag(s) successfully cleared. |
| FSP_ERR_ASSERTION | Null pointer as a parameter. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| FSP_ERR_UNSUPPORTED | This function is only valid if the watchdog generates an NMI/IRQ when an error occurs. |
| fsp_err_t R_WDT_StatusGet | ( | wdt_ctrl_t *const | p_ctrl, |
| wdt_status_t *const | p_status | ||
| ) |
Read the WDT status flags. Implements wdt_api_t::statusGet.
Indicates both status and error conditions.
| FSP_SUCCESS | WDT status successfully read. |
| FSP_ERR_ASSERTION | Null pointer as a parameter. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| FSP_ERR_UNSUPPORTED | This function is only valid if the watchdog generates an NMI/IRQ when an error occurs. |
| fsp_err_t R_WDT_CounterGet | ( | wdt_ctrl_t *const | p_ctrl, |
| uint32_t *const | p_count | ||
| ) |
Read the current count value of the WDT. Implements wdt_api_t::counterGet.
Example:
| FSP_SUCCESS | WDT current count successfully read. |
| FSP_ERR_ASSERTION | Null pointer passed as a parameter. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| fsp_err_t R_WDT_TimeoutGet | ( | wdt_ctrl_t *const | p_ctrl, |
| wdt_timeout_values_t *const | p_timeout | ||
| ) |
Read timeout information for the watchdog timer. Implements wdt_api_t::timeoutGet.
| FSP_SUCCESS | WDT timeout information retrieved successfully. |
| FSP_ERR_ASSERTION | Null Pointer. |
| FSP_ERR_NOT_OPEN | Instance control block is not initialized. |
| fsp_err_t R_WDT_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. |