From 60fba110ffcc9484f6bfcf2d0f5af646b6e9a76a Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Thu, 19 Mar 2020 14:26:47 +0300 Subject: [PATCH] [AVR] use a watchdog to keep this thing from freezing --- Firmware/MotorControl/src/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Firmware/MotorControl/src/main.cpp b/Firmware/MotorControl/src/main.cpp index 5798084..ac17ac3 100644 --- a/Firmware/MotorControl/src/main.cpp +++ b/Firmware/MotorControl/src/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include "Config.h" #include "Globals.h" @@ -72,6 +73,8 @@ void requestEvent() { sts.toBytes(txBuffer); Wire.write(txBuffer, i2cStsBytes); + + wdt_reset(); } void execCommand(Command cmd) { @@ -126,7 +129,7 @@ void setup() { OCR2A = 250; TCCR2A |= (1 << WGM20) | (1 << CS22); TIMSK2 |= (1 << OCIE2A); -} + wdt_enable(WDTO_8S);} volatile unsigned int tick = 0; volatile bool armed = false;