![]() In the video below running the demo code, the program starts normally with a power on or the pushbutton, and LED3 is turned on. End of main loop so "kick" to reset watchdog timer and avoid a reset Simulate a fault lock up with an infinite while loop, but only after 25 loop iterations Myled1 = 1 //Flash LEDs 1 & 2 to indicate normal loop activity Would typically have a lot of code in loop with many calls Main program loop - resets watchdog once each loop iteration needs to be longer than worst case main loop exection time setup a 10 second timeout on watchdog timer hardware ![]() On reset, indicate a watchdog reset or a pushbutton reset on LED 4 or 3 "kick" or "feed" the dog - reset the watchdog timer LPC_WDT->WDMOD = 0x3 // Enabled and Reset ![]() Uint32_t clk = SystemCoreClock / 16 // WD has a fixed /4 prescaler, PCLK default is /4 LPC_WDT->WDCLKSEL = 0x1 // Set CLK src to PCLK ![]() Load timeout value in watchdog timer and enable LEDs used to indicate code activity and reset sourceĭigitalOut myled1(LED1) //in main loop part 1ĭigitalOut myled2(LED2) //in main loop part 2 (where fault occurs)ĭigitalOut myled3(LED3) //The pushbutton or power on caused a resetĭigitalOut myled4(LED4) //The watchdog timer caused a reset Additional information on the watchdog timer can be found in Chapter 28 of the LPC1768 User Manual. It is based on code examples in some earlier forum postings at. Here is a short code example showing how to use the watchdog timer on mbed. Watchdog timers provide a last line of defense to prevent system failure with minimal hardware cost. Such events will occur on the power grid several times a year. Even momentary noise spikes on a power supply can lock up a processor occasionally. In deep space, there is no one around to push a reset button or take out the batteries.ĭespite extensive software and hardware testing, faults will still occur in real devices. In another space mission that was successful, several watchdog resets occurred during the NASA Pathfinder mission to Mars before the code problem was discovered and fixed with new software that was downloaded in deep space via a radio link. A watchdog timer would have likely detected the fault and shut down the rocket motors in time to save the mission. The processor had a watchdog timer but it was not used. By the time the ground controllers realized the problem and sent a radio signal back to force a hardware reset, the probe had used all of the fuel. In one famous case, a NASA deep space probe’s computer locked up with the thruster rockets firing. On the mbed this register is called the Reset Source Identification Register (RSID). Typically after reset, a register can also be read to determine if the watchdog timer generated the reset or if it was a normal reset. Used in this way, the watchdog timer can detect a fault on an unattended embedded device and attempt corrective action with a reset. ![]() If a fault occurs and the main program does not get back to reset the timer before it counts down, an interrupt is generated to reset the processor. Each time it goes through the main loop the code resets the watchdog timer (sometimes called “kicking” or “feeding” the dog). The watchdog timer is loaded with an initial value greater than the worst case time delay through the main program loop. The main program typically has a loop that it constantly goes through performing various functions. Many microcontrollers including the mbed processor have watchdog timer hardware. Some systems may also refer to it as a computer operating properly (COP) timer. It is often used to automatically reset an embedded device that hangs because of a software or hardware fault. A watchdog timer (WDT) is a hardware timer that automatically generates a system reset if the main program neglects to periodically service it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |