Поковырял их на Arduino-платках c Ali. 1) Большинство чипов имеют
баг WDT: при переходе по прерыванию улетает на перезагрузку; при
этом опрос флага работает(см. ниже). 2) при использовании внешнего
осциллятора или кварца надо не только PMCR настроить, но и в PMX2
взвести бит. https://github.com/dbuezas/lgt8fx/issues/263
As @wollewald mentioned in his article most of the LGT8F328P have Watchdog error. This error causes that the watchdog interrupt not working and jumping to the reset vector instead. So with this error the watchdog timer is mainly useful only for watchdog reset.
- When WDT set to watchdog reset mode its working as expected.
- When WDT set to watchdog interrupt mode and when the timer expires the WDIF bit will be set in WDTCSR register and the program will continue to run until interrupts not enabled. After enabling the interrupts the CPU immediately jumps to reset vector, but the WDIF bit remains set.
It is possible to create a code snippet in the init procedure which detecting the WDT error. If the error exist it is detectable trough WDIF bit. If no WDT interrupt error in the chip the WDIF bit will be cleared by WDT interrupt and no jump to reset vector.
At the end a flag can be set for a user can see if the chip is faulty.