RSS

Welcome! Sign in New to NXP LPC1100? JOIN NOW

Watchdog my real example below.

I want to share my code for Watchdog Timer Reset function, for case if code will gone to error state. The Watchdog timer will reset the MCU in 10sec with 40%. So, if you want to prevent the reset feed the register in proper time.

LPC_SYSCON->PDRUNCFG &= ~(1 << 6);
LPC_SYSCON->SYSAHBCLKCTRL |= (0x01 << 15);
LPC_SYSCON->WDTOSCCTRL = ((0x01 << 7) | (0x01 << 6) | (0x01 << 5)); // Set to 1MHz
LPC_SYSCON->WDTCLKSEL = (0x01 << 1);
LPC_SYSCON->WDTCLKUEN = 0x00;
LPC_SYSCON->WDTCLKUEN = 0x01;
while (!(LPC_SYSCON->WDTCLKUEN & 0x01));
LPC_SYSCON->WDTCLKDIV = 100; // Divide the main clock by 100, so each WDT clock will be at 0.1msec

__disable_irq();
LPC_WDT->TC = 25000; // Reset will happen every 10sec with 40% accuracy in time
LPC_WDT->MOD = ((0x01 << 1) | (0x01 << 0));
LPC_WDT->FEED = 0xAA;
LPC_WDT->FEED = 0x55;
__enable_irq();