Part Number: F28M35H52C
Hi all. This is my first post, so please be kind.
I modified the M3 watchdog example code to make it more compact for this demonstration and to use macros to switch between the watchdog timers. See resulting code that follows:
//uncomment four lines below to use WDT0
//#define DOGBASE WATCHDOG0_BASE //#define DOGPERI SYSCTL_PERIPH_WDOG0 //#define DOGWAIT //#define DOGCLOCK (SysCtlClockGet(SYSTEM_CLOCK_SPEED)) // uncomment four lines below to use WDT1
#define DOGBASE WATCHDOG1_BASE #define DOGPERI SYSCTL_PERIPH_WDOG1 #define DOGWAIT while(!WatchdogWriteReady()); #define DOGCLOCK (SYSTEM_CLOCK_SPEED) void main(void) { SysCtlClockConfigSet(SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 | SYSCTL_USE_PLL | (SYSCTL_SPLLIMULT_M & 0x0F)); #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); FlashInit(); #endif IntRegister(INT_WATCHDOG, WatchdogTimerHandler); SysCtlPeripheralEnable(DOGPERI); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_6); GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, 0); DOGWAIT WatchdogUnlock(DOGBASE); IntEnable(INT_WATCHDOG); IntMasterEnable(); DOGWAIT WatchdogReloadSet(DOGBASE, DOGCLOCK); DOGWAIT WatchdogResetEnable(DOGBASE); DOGWAIT WatchdogEnable(DOGBASE); DOGWAIT WatchdogLock(DOGBASE); while(1); } void WatchdogTimerHandler (void) { if(!g_bFeedWatchdog) return; DOGWAIT WatchdogIntClear(DOGBASE); GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6,(GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_6) ^ GPIO_PIN_6)); g_InterruptCount++; }
To switch between WDT0 and WDT1, comment out the appropriate four lines at the beginning of this snippet. When WDT0 is selected, this code runs just like the TI example code. No problems. When WDT1 is selected, the code hangs waiting for the Write Complete bit (WRC) in the WDTCTL register immediately after the WatchdogReloadSet(DOGBASE, DOGCLOCK); call. With the debugger, I can see that the WRC bit really is stuck at zero. I also see the WDTVALUE is counting down and I also see that the write to the WDTLOAD register (SYSTEM_CLOCK_SPEED) didn't take and the WDTLOAD value remains 0xFFFFFFFF.
Any insight into what I'm doing wrong would be appreciated.
Thanks