Joules120 0 Posted October 9, 2015 Share Posted October 9, 2015 Hello. I need to use the watchdog but I can't find any information about it. Can someone help me please? Quote Link to post Share on other sites
abecedarian 330 Posted October 9, 2015 Share Posted October 9, 2015 @@Joules120 The watchdog does things for Energia. Perhaps if you explained, in detail, what you need, someone can help you get what you need. hungtran 1 Quote Link to post Share on other sites
maelli01 74 Posted November 7, 2015 Share Posted November 7, 2015 converted the watchdog example from Tivaware into Energia. it should explain itself... I tested this with the connected launchpad TM4C1294 5 blinks, resets itself, 5 blinks, on and on.... /* 6.11.2015 Watchdog example */ #define LED RED_LED #include <stdint.h> #include <stdbool.h> #include "driverlib/sysctl.h" #include "driverlib/watchdog.h" unsigned long oldmillis; unsigned int timeout; void setup() { pinMode(LED, OUTPUT); SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); WatchdogReloadSet(WATCHDOG0_BASE,120000000); WatchdogResetEnable(WATCHDOG0_BASE); } // the loop routine runs over and over again forever: void loop() { if (millis()>(oldmillis+500)){ oldmillis=millis(); digitalWrite(LED, HIGH); delay(100); digitalWrite(LED, LOW); timeout++; WatchdogReloadSet(WATCHDOG0_BASE,120000000); //feed the dog, food for a second ;-) // simulated software crash: dog will not be fed any longer, causing a reset if (timeout>5){ while(1); } } } CorB and energia 2 Quote Link to post Share on other sites
energia 485 Posted January 7, 2016 Share Posted January 7, 2016 Answering a different thread, I just now discovered this thread. http://forum.43oh.com/topic/9240-watchdog-timer-for-tiva-tm4c1294ncpdt/ Below is a bit more extensive example of how to use the watchdog timer to reset the system using interrupts. The idea is that when you press USR_SW1 once, the watchdog will be starved and a system reset is triggered: #include <stdint.h> #include <stdbool.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/fpu.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "driverlib/watchdog.h" #include "driverlib/rom_map.h" #include "driverlib/rom.h" uint8_t feedWatchdog = true; uint8_t ledState = true; long lastDebounceTime = 0; // the last time the output pin was toggled long debounceDelay = 100; // the debounce time; increase if the output flickers int lastButtonState = HIGH; // the previous reading from the input pin void setup() { Serial.begin(115200); pinMode(PUSH1, INPUT_PULLUP); pinMode(GREEN_LED, OUTPUT); digitalWrite(GREEN_LED, HIGH); // Enable the watchdog peripheral MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); // Set timeout of watchdog to 2 sec MAP_WatchdogReloadSet(WATCHDOG0_BASE, MAP_SysCtlClockGet() * 2); // Reset when watchdog expires MAP_WatchdogResetEnable(WATCHDOG0_BASE); // Register the watchdog interrupt handler WatchdogIntRegister(WATCHDOG0_BASE, &WatchdogIntHandler); // Enable the watchdog MAP_WatchdogEnable(WATCHDOG0_BASE); // Get and print the reset cause if(SysCtlResetCauseGet() & SYSCTL_CAUSE_WDOG0) { Serial.println("WatchDog Reset"); }else if(SysCtlResetCauseGet() & SYSCTL_CAUSE_EXT) { Serial.println("External reset"); } SysCtlResetCauseClear(SYSCTL_CAUSE_WDOG0 | SYSCTL_CAUSE_EXT); } void loop() { // Read the button that triggers starving the Watchdog int reading = digitalRead(PUSH1); // If the switch changed, due to noise or pressing: if (reading != lastButtonState) { // reset the debouncing timer lastDebounceTime = millis(); } if (((millis() - lastDebounceTime) > debounceDelay) && lastButtonState == LOW) { // If the button has been low for longer than the debounce time, starve the Watchdog. feedWatchdog = false; } // save the reading. Next time through the loop, // it'll be the lastButtonState: lastButtonState = reading; } void WatchdogIntHandler(void) { // // If we have been told to stop feeding the watchdog, return immediately // without clearing the interrupt. This will cause the system to reset // next time the watchdog interrupt fires. // if(!feedWatchdog) { return; } // // Clear the watchdog interrupt. // WatchdogIntClear(WATCHDOG0_BASE); digitalWrite(GREEN_LED, ledState); ledState = !ledState; } Quote Link to post Share on other sites
khm 0 Posted May 4, 2016 Share Posted May 4, 2016 How do I calculate the timing for watchdog reset? @@energia Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.