I am in the process of adding a STWD100 watchdog timer to my photonAlarm project. I have a test device on a breakout board and have it connected to a Photon. The photonAlarm code includes a c++ class hwd, and I have a small test routine which uses this class to test the device.
With a Saleae Logic Analyzer attached to the device pins, I can see that the device is performing
correctly. With a loop time of 1000ms the checkin pulse on WDI keeps the timer reset, and the
WDO reset line remains high. When the loop time is changed to 2000ms, the checkin pulse is late, and the WDO line pulses low to perform a reset. You can see screenshots of the logic analyzer here:
https://github.com/dont45/photonMasterRemote/wiki on the Watchdog Timer page.
All of the code is in this repository on the Code page.
The STWD100 is connected to the Photon reset line as shown in Fig.4 of ST’s device documentation pdf. On the Main page of my wiki, the circuit show does not include the 10K resistor on the RST line, pulling it HI to vcc. I have tried this both with and without this resistor.
Question / Problem:
My problem is that the the Photon goes into a constant cycle of resets when the device is connected to the reset line. There seems to be some timing issue with getting the Photon to pull the EN line high during startup, and therefore disable the STWD device, until is is properly configured [by hwd.init()], and enabled as a last thing in setup() [by had.enable()].
Has anyone worked with this device? I really like hardware watchdog timers since they provide another independent way of ensuring that the microprocessor and it’s firmware are running properly. I greatly appreciate any help in resolving this issue.
Thanks, Don
Debug Code:
Node: hwd.h and hwd.cpp are available in the code repository.
/*
TESTING HARDWARE WATCHDOG
Master-Remote alarm system for Particle Photon
@file Debug-Alarm-Master.cpp
@author D. Thompson
@license GNU General Public License (see license.txt)
@version 3.1.0
Copyright (C) 2016 Donald Thompson, Raynham Engineering
*/
#include "application.h"
#include "hwd.h"
#define HARDWARE_WATCHDOG
#define SERIAL_DEBUG
#define SERIAL_DEBUGXX
#define SERIAL_WAIT
#define LOOP_DELAY_TIME 1000 //Delay ms between loop passes
#define SYSTEM_STATUS_PIN D2 //RED if Armed, Blinking if any tripped
#define SYSTEM_NOTIFICATION_PIN D3 //GREEN blinks at each loop ??
#define TRIGGER_PIN D4 //debug pin for logic analyzer trigger
int loop_count;
int ledStatus = SYSTEM_STATUS_PIN; //blink this LED at each loop pass
int ledNotice = SYSTEM_NOTIFICATION_PIN; //blink this LED at each notification
HWD hwd;
void setup() {
pinMode(HWD_EN_PIN, OUTPUT);
digitalWrite(HWD_EN_PIN, HIGH);
pinMode(TRIGGER_PIN, OUTPUT);
digitalWrite(TRIGGER_PIN, LOW);
loop_count = 0;
#ifdef SERIAL_DEBUG
Serial.begin(9600);
#ifdef SERIAL_WAIT
while(!Serial.available()) // Wait here until the user presses ENTER
Spark.process(); // in the Serial Terminal. Call the BG Tasks
Serial.read();
#endif
#endif
Serial.println("Debug initializing...");
Serial.println("starting watchdog");
digitalWrite(TRIGGER_PIN, HIGH);
hwd.init();
#ifdef HARDWARE_WATCHDOG
hwd.disable();
delay(500);
hwd.enable();
#endif;
}
//LOOP IS testing hardware watchdog reset.
//SHOULD reset at arount 2 seconds without checkin
void loop() {
#ifdef SERIAL_DEBUG
Serial.print(".");
#endif
delay(LOOP_DELAY_TIME);
//wd.checkin() done automatically at end of each loop
#ifdef SERIAL_DEBUG
loop_count++;
Serial.print("cnt:");
Serial.println(loop_count);
#endif
#ifdef HARDWARE_WATCHDOG
hwd.checkin();
#endif
}