Jump to content
43oh

Recommended Posts

Dear Experts,

now i am working with TivaC TM4C123GH6PM an energia. i never work in watch dog timer before so i was rewrite the watch dog timer example code(i get code from google) like below, 

#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/watchdog.h"
#include "driverlib/rom_map.h"
#include "driverlib/rom.h"

void setup()
{
Serial.begin(9600);
Serial.println("SETUP");

MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); // Enable the watchdog peripheral

MAP_WatchdogReloadSet(WATCHDOG0_BASE, MAP_SysCtlClockGet() * 2); // Set timeout of watchdog to 2 sec

MAP_WatchdogResetEnable(WATCHDOG0_BASE); // Reset when watchdog expires

WatchdogIntRegister(WATCHDOG0_BASE, &WatchdogIntHandler); // Register the watchdog interrupt handler

MAP_WatchdogEnable(WATCHDOG0_BASE); // Enable the watchdog

if(SysCtlResetCauseGet() & SYSCTL_CAUSE_WDOG0) // Get and print the reset cause
{
Serial.println("Watchdog Reset");
}
else if(SysCtlResetCauseGet() & SYSCTL_CAUSE_EXT)
{
Serial.println("External reset");
}

SysCtlResetCauseClear(SYSCTL_CAUSE_WDOG0 | SYSCTL_CAUSE_EXT);
}

void loop()
{
Serial.println("MC Working");
delay(6000);
}

void WatchdogIntHandler(void)
{
WatchdogIntClear(WATCHDOG0_BASE); // Clear the watchdog interrupt.
Serial.println("REG CLEAR");
}

 

this code reset the watch dog timer register in every 2 sec, so watchdog is not resetting my controller,  my doubt is this code is definitely reset the controller if my controller getting struck or hang for any disturbance.

please make sure about this.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...