Since Paul found a patch for the reset I started working back on the watchdog interface. The previous version was only for watchdog1 (WDOG1). This redesigned model is templated, and works on ALL 3 watchdogs (WDOG1,WDOG2,RTWDOG(WDOG3)).
I also added Paul's fix to the library so it works on previous teensyduinos as well
I will shortly try to finish up the examples for all the 3 of the watchdogs. WDOG2 is slightly different than WDOG1 as it doesn't actually do an internal reset, and the callback is fired based on the watchdog feeding trigger threshold. However, WDOG1 and WDOG2 both can drive gpios LOW to reset external devices, only WDOG1 can do an internal reset.
The 3 watchdogs have different behaviours.
WDOG1 pins implemented and tested. Expected behaviour: after a watchdog reset (not callback fire), the pins are constantly driven LOW, a POR is needed to reset this state.
WDOG2 pins implemented and tested. Expected behaviour: on timeout (not callback fire), the GPIO goes LOW for a brief second by hardware and then restores GPIO state. T4 does not reset as WDOG2 doesn't do software reset, only GPIO. Not feeding the dog will trigger that pulse ONLY once, your callback will not refire, nor will Teensy reset or toggle the GPIO. When feeding the watchdog, the callback will re-fire and the GPIO will toggle again.
WDOG1 available pins: 19, 20
WDOG2 available pins: 13, 24
WDOG3 (RTWDOG) is different than the other two. It's based not on time, but cycles. To make this easier for the user, the LPO clock is 32KHz, with a 16bit timeout field. The library does the necessary calculations for a user to input timeout value between 32(ms) -> 522.232(seconds).
It features a windowMode, that when enabled, if you feed the dog faster than your threshold, it will reset teensy. It will still reset if the dog is NOT fed whether you use windowMode or not.
The callback for WDOG3 is also different from the other 2 watchdogs, it is not called earlier like a trigger, it's fired 255 cycles before the actual reset, so you have little time to collect diagnostic info before the reset happens.
I also added reset() to be able to reset the MCU immediately when requested.
https://github.com/tonton81/WDT_T4
EDIT, all 3 demos have been posted. WDOG2 demonstrates the GPIO usage, the config.pin can be applied to WDOG1 also for pins 19 or 20 only. WDOG3 pins not implemented yet.
I also added Paul's fix to the library so it works on previous teensyduinos as well
I will shortly try to finish up the examples for all the 3 of the watchdogs. WDOG2 is slightly different than WDOG1 as it doesn't actually do an internal reset, and the callback is fired based on the watchdog feeding trigger threshold. However, WDOG1 and WDOG2 both can drive gpios LOW to reset external devices, only WDOG1 can do an internal reset.
The 3 watchdogs have different behaviours.
WDOG1 pins implemented and tested. Expected behaviour: after a watchdog reset (not callback fire), the pins are constantly driven LOW, a POR is needed to reset this state.
WDOG2 pins implemented and tested. Expected behaviour: on timeout (not callback fire), the GPIO goes LOW for a brief second by hardware and then restores GPIO state. T4 does not reset as WDOG2 doesn't do software reset, only GPIO. Not feeding the dog will trigger that pulse ONLY once, your callback will not refire, nor will Teensy reset or toggle the GPIO. When feeding the watchdog, the callback will re-fire and the GPIO will toggle again.
WDOG1 available pins: 19, 20
WDOG2 available pins: 13, 24
WDOG3 (RTWDOG) is different than the other two. It's based not on time, but cycles. To make this easier for the user, the LPO clock is 32KHz, with a 16bit timeout field. The library does the necessary calculations for a user to input timeout value between 32(ms) -> 522.232(seconds).
It features a windowMode, that when enabled, if you feed the dog faster than your threshold, it will reset teensy. It will still reset if the dog is NOT fed whether you use windowMode or not.
The callback for WDOG3 is also different from the other 2 watchdogs, it is not called earlier like a trigger, it's fired 255 cycles before the actual reset, so you have little time to collect diagnostic info before the reset happens.
I also added reset() to be able to reset the MCU immediately when requested.
https://github.com/tonton81/WDT_T4
EDIT, all 3 demos have been posted. WDOG2 demonstrates the GPIO usage, the config.pin can be applied to WDOG1 also for pins 19 or 20 only. WDOG3 pins not implemented yet.
Last edited: