Line 17... |
Line 17... |
|
|
The watchdog (WDT) provides a last resort for safety-critical applications. The WDT has an internal 20-bit
|
The watchdog (WDT) provides a last resort for safety-critical applications. The WDT has an internal 20-bit
|
wide counter that needs to be reset every now and then by the user program. If the counter overflows, either
|
wide counter that needs to be reset every now and then by the user program. If the counter overflows, either
|
a system reset or an interrupt is generated (depending on the configured operation mode).
|
a system reset or an interrupt is generated (depending on the configured operation mode).
|
|
|
Configuration of the watchdog is done by a single control register _WDT_CT_. The watchdog is enabled by
|
Configuration of the watchdog is done by a single control register `CTRL`. The watchdog is enabled by
|
setting the _WDT_CT_EN_ bit. The clock used to increment the internal counter is selected via the 3-bit
|
setting the _WDT_CTRL_EN_ bit. The clock used to increment the internal counter is selected via the 3-bit
|
_WDT_CT_CLK_SELx_ prescaler:
|
_WDT_CTRL_CLK_SELx_ prescaler:
|
|
|
[cols="^3,^3,>4"]
|
[cols="^3,^3,>4"]
|
[options="header",grid="rows"]
|
[options="header",grid="rows"]
|
|=======================
|
|=======================
|
| **`WDT_CT_CLK_SELx`** | Main clock prescaler | Timeout period in clock cycles
|
| **`WDT_CTRL_CLK_SELx`** | Main clock prescaler | Timeout period in clock cycles
|
| `0b000` | 2 | 2 097 152
|
| `0b000` | 2 | 2 097 152
|
| `0b001` | 4 | 4 194 304
|
| `0b001` | 4 | 4 194 304
|
| `0b010` | 8 | 8 388 608
|
| `0b010` | 8 | 8 388 608
|
| `0b011` | 64 | 67 108 864
|
| `0b011` | 64 | 67 108 864
|
| `0b100` | 128 | 134 217 728
|
| `0b100` | 128 | 134 217 728
|
Line 37... |
Line 37... |
| `0b111` | 4096 | 4 294 967 296
|
| `0b111` | 4096 | 4 294 967 296
|
|=======================
|
|=======================
|
|
|
Whenever the internal timer overflows the watchdog executes one of two possible actions: Either a hard
|
Whenever the internal timer overflows the watchdog executes one of two possible actions: Either a hard
|
processor reset is triggered or an interrupt is requested at CPU's fast interrupt channel #0. The
|
processor reset is triggered or an interrupt is requested at CPU's fast interrupt channel #0. The
|
WDT_CT_MODE bit defines the action to be taken on an overflow: When cleared, the Watchdog will trigger an
|
WDT_CTRL_MODE bit defines the action to be taken on an overflow: When cleared, the Watchdog will trigger an
|
IRQ, when set the WDT will cause a system reset. The configured actions can also be triggered manually at
|
IRQ, when set the WDT will cause a system reset. The configured actions can also be triggered manually at
|
any time by setting the _WDT_CT_FORCE_ bit. The watchdog is reset by setting the _WDT_CT_RESET_ bit.
|
any time by setting the _WDT_CTRL_FORCE_ bit. The watchdog is reset by setting the _WDT_CTRL_RESET_ bit.
|
|
|
The cause of the last action of the watchdog can be determined via the _WDT_CT_RCAUSE_ flag. If this flag is
|
The cause of the last action of the watchdog can be determined via the _WDT_CTRL_RCAUSE_ flag. If this flag is
|
zero, the processor has been reset via the external reset signal. If this flag is set the last system reset was
|
zero, the processor has been reset via the external reset signal. If this flag is set the last system reset was
|
initiated by the watchdog.
|
initiated by the watchdog.
|
|
|
The Watchdog control register can be locked in order to protect the current configuration. The lock is
|
The Watchdog control register can be locked in order to protect the current configuration. The lock is
|
activated by setting bit _WDT_CT_LOCK_. In the locked state any write access to the configuration flags is
|
activated by setting bit _WDT_CTRL_LOCK_. In the locked state any write access to the configuration flags is
|
ignored (see table below, "accessible if locked"). Read accesses to the control register are not effected. The
|
ignored (see table below, "accessible if locked"). Read accesses to the control register are not effected. The
|
lock can only be removed by a system reset (via external reset signal or via a watchdog reset action).
|
lock can only be removed by a system reset (via external reset signal or via a watchdog reset action).
|
|
|
.WDT register map
|
.WDT register map (`struct NEORV32_WDT`)
|
[cols="<2,<2,<4,^1,^2,<4"]
|
[cols="<2,<2,<4,^1,^2,<4"]
|
[options="header",grid="all"]
|
[options="header",grid="all"]
|
|=======================
|
|=======================
|
| Address | Name [C] | Bit(s), Name [C] | R/W | Writable if locked | Function
|
| Address | Name [C] | Bit(s), Name [C] | R/W | Writable if locked | Function
|
.9+<| `0xffffffbc` .9+<| _WDT_CT_ <|`0` _WDT_CT_EN_ ^| r/w ^| no <| watchdog enable
|
.9+<| `0xffffffbc` .9+<| `NEORV32_WDT.CTRL` <|`0` _WDT_CTRL_EN_ ^| r/w ^| no <| watchdog enable
|
<|`1` _WDT_CT_CLK_SEL0_ ^| r/w ^| no .3+<| 3-bit clock prescaler select
|
<|`1` _WDT_CTRL_CLK_SEL0_ ^| r/w ^| no .3+<| 3-bit clock prescaler select
|
<|`2` _WDT_CT_CLK_SEL1_ ^| r/w ^| no
|
<|`2` _WDT_CTRL_CLK_SEL1_ ^| r/w ^| no
|
<|`3` _WDT_CT_CLK_SEL2_ ^| r/w ^| no
|
<|`3` _WDT_CTRL_CLK_SEL2_ ^| r/w ^| no
|
<|`4` _WDT_CT_MODE_ ^| r/w ^| no <| overflow action: `1`=reset, `0`=IRQ
|
<|`4` _WDT_CTRL_MODE_ ^| r/w ^| no <| overflow action: `1`=reset, `0`=IRQ
|
<|`5` _WDT_CT_RCAUSE_ ^| r/- ^| - <| cause of last system reset: `0`=caused by external reset signal, `1`=caused by watchdog
|
<|`5` _WDT_CTRL_RCAUSE_ ^| r/- ^| - <| cause of last system reset: `0`=caused by external reset signal, `1`=caused by watchdog
|
<|`6` _WDT_CT_RESET_ ^| -/w ^| yes <| watchdog reset when set, auto-clears
|
<|`6` _WDT_CTRL_RESET_ ^| -/w ^| yes <| watchdog reset when set, auto-clears
|
<|`7` _WDT_CT_FORCE_ ^| -/w ^| yes <| force configured watchdog action when set, auto-clears
|
<|`7` _WDT_CTRL_FORCE_ ^| -/w ^| yes <| force configured watchdog action when set, auto-clears
|
<|`8` _WDT_CT_LOCK_ ^| r/w ^| no <| lock access to configuration when set, clears only on system reset (via external reset signal OR watchdog reset action = reset)
|
<|`8` _WDT_CTRL_LOCK_ ^| r/w ^| no <| lock access to configuration when set, clears only on system reset (via external reset signal OR watchdog reset action = reset)
|
|=======================
|
|=======================
|