My sketch seems to hang on BOOT for no apparent reason and can hang anywhere from <1Hour toweeks.
When I REBOOT, sketch runs ok - until it hangs.
To overcome this, I need to implement an external WDT.
#include<avr/wdt.h>
int HeartbeatPin = 13;
void setup() {
wdt_disable(); // Disable the watchdog timer
delay(100);
Serial.begin(115200); // Enable Serial
// DEBUG
Serial.println(F("-----------------------------"));// The F() syntax copies the string to Flash Memory
delay(50);
Serial.println(F("BOOT"));// The F() syntax copies the string to Flash Memory
delay(50);
Serial.println(F("Initial Heartbeat - SETUP"));// The F() syntax copies the string to Flash Memory
delay(50);
heartbeat();
}
void loop() {
Serial.println(F("Heartbeat - LOOP"));// The F() syntax copies the string to Flash Memory
heartbeat();
delay(1.5 * 30000UL);
}
void heartbeat() {
// Sink current to drain C2
pinMode(HeartbeatPin, OUTPUT);
digitalWrite(HeartbeatPin, LOW);
delay(300);
// Set pin back to High Impedance
pinMode(HeartbeatPin, INPUT);
}
When a heartbeat is received by the 555 within the period expected by the 555 (delay(1 * 30000UL) all is OK and I receive the following on the Serial Monitor:
The problem I have is that when I increase the sending of the heartbeat to greater than the 555 expects (delay(1.5 * 30000UL) the Arduino should REBOOT.
I have checked the circuit and all is OK with the reset line going LOW from the 5 seconds.
When the 555 attempts a REBOOT, I receive the following on the Serial Monitor:
gciurpita:
why is the HeartbeatPin being reconfigured as an OUTPUT and back to an INPUT using pinMode?
shouldn't the pin be made LOW and then HIGH?
does the the pin really need to be held LOW for 300 msec?
From the link above:
It is not sufficient to just make the Output pin LOW to restart the timer, but afterwards it needs to be set HIGH again. However, even if an output pin is HIGH, there still is an internal impedance that could drain C2. Therefore after setting it as OUTPUT and LOW, we set it back to INPUT mode again, because as input the I/O pins of the Arduino have a fairly high impedance
gciurpita:
why do expect the voltage to be on the pin when it is configured as an INPUT?
It is not sufficient to just make the Output pin LOW to restart the timer, but afterwards it needs to be set HIGH again. However, even if an output pin is HIGH, there still is an internal impedance that could drain C2. Therefore after setting it as OUTPUT and LOW, we set it back to INPUT mode again, because as input the I/O pins of the Arduino have a fairly high impedance
owever, even if an output pin is HIGH, there still is an internal impedance that could drain C2
can you post a circuit diagram?
the discharge pin is normally connected thru a resistor to discharge the capacitor when the voltage of the cap exceeds 2/3 Vcc on the threshold pin. you must not be relying on this to discharge the cap because it would cause a reset.
it sounds like you connected the output pin to the capacitor, possibly thru a resistor to discharge it. that's why don't want the output pin to be high.
i think (pending seeing the circuit diagram) you really need an external transistor to discharge the cap (instead of using the discharge pin. i had assumed this is what you were doing.