Please sign in to comment.
fix: Bug causing the watchdog timer to continously reboot
In all USBaspLoader version up to 0.97 exists a bug, which causes the watchdog timer to continously reboot. When a users firmware activates the watchdog timer, and then times out: The MCUC(S)R register then has WDRF bit to HIGH. On some ATmegas this keeps the AVRs internal hardware reset from disabling the active watchdog (even when the WDTON fuse is unprogrammed). However the timeout period is reset anyway to minimal value of 16ms (WDPx to LOW). In the bootloaders PROG-PIN chargeup phase, the bootloader stalls about 50ms, causing the AVR to reboot. For deactivating the watchdog timer, some AVRs need to reset the WDRF bit first. But since also the hardware reset seems to be restricted to this measure (hardware bug???), the watchdog stays on forever - even during RESET presses. This also renders the RESET pin/button effectivly useless. This patch fixes this issue by redesigning internal time management. Now all relevant delays are based on _mywait, which might execute an additional WDR (watchdog timer refresh) when neccessary. So active watchdog timers are now keept alive until it is shure that bootloaderCondition() is true. As always: In situation where bootloaderCondition() is false, user firmwares can rely on active watchdog then. Signed-off-by: Stephan Baerwolf <email@example.com>
- Loading branch information...
Showing with 31 additions and 29 deletions.