MOD54415 Watchdog timer implementation
Posted: Thu May 08, 2014 8:49 am
Hi,
I am trying to include software watchdog in my code to reset the Netburner in case I get stuck in a loop in my code. I looked up the example for the SBL2E and slightly modified it for MOD54415. My code is include below.
I ran this code but it counts the seconds fine and never restarts even though I have commented out the write of 0x55 and 0xAA to CWSR register. What I might be doing incorrectly? I will appreciate any help in this matter.
Regards,
TM
I am trying to include software watchdog in my code to reset the Netburner in case I get stuck in a loop in my code. I looked up the example for the SBL2E and slightly modified it for MOD54415. My code is include below.
Code: Select all
///included
#include "predef.h"
#include <stdio.h>
#include <stdlib.h>
#include <basictypes.h>
#include <ucos.h>
#include <ctype.h>
#include <startnet.h>
#include <autoupdate.h>
#include <dhcpclient.h>
#include <taskmon.h>
#include <smarttrap.h>
#include <effs_fat/fat.h>
#include <effs_fat/multi_drive_mmc_mcf.h>
#include <effs_fat/effs_utils.h>
#include <sim.h>
#include <pins.h>
#include <ucosmcfc.h>
#include <pinconstant.h>
#include <HiResTimer.h>
#include <utils.h>
#include <constants.h>
#include <cfinter.h>
#include <math.h>
#include <serial.h>
#include <dspi.h>
#include <bsp.h>
extern "C" {
void UserMain(void * pd);
void SetIntc(long func, int vector, int level, int prio);
}
const char * AppName="wdExample";
/*
* Interrupt occurs if watchdog is not periodically touched. In this case, a hardware reboot will occur
*/
INTERRUPT( wdReset, 0x2700 )
{
ForceReboot();
}
/*
* Task that periodically touches watchdog. If not called, an interrupt will be triggered and
* wdReset will force reboot.
*/
void wdTouch( void *)
{
while(1)
{
OSTimeDly(TICKS_PER_SECOND);
// sim2.scm.cwsr = 0x55; /******I commented out this portion so that I actually see the netburner restart**********/
// sim2.scm.cwsr = 0xAA;
}
}
void UserMain(void * pd) {
InitializeStack();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();
#ifndef _DEBUG
EnableSmartTraps();
#endif
int fd0=0;
SerialClose(0);
fd0=OpenSerial( 0, 115200, 1, 8, eParityNone );//
OSSimpleTaskCreate(wdTouch,MAIN_PRIO-1);
SetIntc((long) &wdReset,25, 6, 3 ); /**********Level 6 interrupt for source 25 of INTC0 on MOD54415*********/
iprintf("Starting Watchdog in 5 seconds\r\n");
OSTimeDly(5*TICKS_PER_SECOND);
sim2.scm.cwcr = 0x819F;/******Starting Watchdog timer**********/
iprintf("Application started\n");
int seconds = 0;
while (1) {
iprintf("%d\r\n",seconds++);
OSTimeDly(20);
}
}
Regards,
TM