Jump to content

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()

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");


void loop()
Serial.println("MC Working");

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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now