The purpose of the watchdog is to generate a reset when an error occurs in the microprocessor. When the watchdog is enabled, if the user does not feed the watchdog within the overflow period (reload the timing value for the watchdog timer), the system will reset.
/************************************************************************************************
Function name: void WDTInit( void )
Function function: Initialize watchdog timer
Parameter: timeout timer
Return value: None
****************************************************************************************/
void WDTInit( uint32_t timeout )
{
//Default peripheral power register is enabled
// First step to initialize watchdog
Chip_WWDT_Init(LPC_WWDT);
// Second step to set timer time
Chip_WWDT_SetTimeOut(LPC_WWDT,timeout); //Set timer time
// Third step to enable watchdog, reset system after timer overflows
Chip_WWDT_SetOption(LPC_WWDT, WWDT_WDMOD_WDRESET|WWDT_WDMOD_WDEN);//Reset and enable
// Fourth step to feed dog
Chip_WWDT_Feed(LPC_WWDT);//Feed dog
}
/************************************************************************************************
Function name: void WDTFeed( void )
Function function: feed the watchdog timer to prevent it from timing out
Parameter: None
Return value: None
Note that the watchdog feeding function is a repeat of the previous one. In fact, directly calling Chip_WWDT_Feed(LPC_WWDT); the function effect is the same
****************************************************************************************************/
void WDTFeed( void )
{
Chip_WWDT_Feed(LPC_WWDT);
}
【06】LPC1768_看门狗实验.rar
(249.62 KB, downloads: 20)
This content is originally created by EEWORLD forum user cxmdz . If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source