User`s manual

RX62N Group, RX621 Group 5. Usage Examples
5.11. Independent Watchdog Timer
Figure 5-18 shows an example of Independent Watchdog timer usage.
At start-up the underflow is checked to identify if the the reset was caused by the Independent Watchdog timer.
The watchdog timer is then configured for a 1024-count timeout period and started.
Because the watchdog timer is not refreshed, after two seconds (this depends on the frequency of the on-chip
oscillator) the MCU is reset and the underflow condition is detected.
/* Peripheral driver function prototypes */
#include "r_pdl_iwdt.h"
/* PDL device-specific definitions */
#include "r_pdl_definitions.h"
void main(void)
{
uint16_t Status;
/* Read the timer status */
R_IWDT_Read(
&Status
);
/* Has an underflow occurred? */
if ((Status & BIT_14) != 0x0u)
{
/* Handle the watchdog-induced reset here */
}
/* Configure the IWDT */
R_IWDT_Set(
PDL_IWDT_TIMEOUT_1024 | PDL_IWDT_CLOCK_OCO_256
);
/* Start the IWDT */
R_IWDT_Control(
PDL_IWDT_REFRESH
);
}
Figure 5-18: Example of Independent Watchdog Timer use
R20UT0084EE0112 Rev.1.12 Page 5-34
July. 16, 2014