AnsweredAssumed Answered

watchdog reset not getting back to main

Question asked by Kevin Alden on Jul 24, 2015
Latest reply on Jul 27, 2015 by Kevin Alden

I have a simple MQX application based on the watchdog example app.  I start an MQX task, initialize the watchdog, and then feed it in a loop unless a button is pressed on the board.  If I hold the button to force a watchdog reset the watchdog does trigger, but I never get back to my task.  Any idea why this would happen?  I'm using KSDK 1.2.0 and a TWR-K64F120M. Code below:

void configureWatchdog(int timeoutSeconds)

{

   const uint32_t wdog_clock_hz = 1024;

 

 

   const wdog_config_t wdog_config

   {

      .wdogEnable                = true,// Watchdog mode

      .clkSrc                    = kWdogLpoClkSrc, // Watchdog clock source is LPO 1KHz

      .prescaler                 = kWdogClkPrescalerDivide1, // Watchdog clock prescaler

      .workMode =

      {

         .kWdogEnableInWaitMode  = true, // Enable watchdog in wait mode

         .kWdogEnableInStopMode  = true, // Enable watchdog in stop mode

         .kWdogEnableInDebugMode = false,// Disable watchdog in debug mode

      },

      .updateEnable              = true, // Update register enabled

      .intEnable                 = false,

      .winEnable                 = false, //Disable window function

      .windowValue               = 0,    // Watchdog window value

      .timeoutValue              = timeoutSeconds * wdog_clock_hz,// Watchdog overflow time

 

 

 

 

   };

 

 

   WDOG_DRV_Init(&wdog_config);

}

 

bool watchdogReboot()

{

   return (RCM->SRS0 & RCM_SRS0_WDOG_MASK) > 0;

}

 

void Main_Task(uint32_t unused)

{

   _int_install_unexpected_isr();

 

 

 

   for (size_t i = 0; i < PORT_INSTANCE_COUNT; i++)

   {

      CLOCK_SYS_EnablePortClock(i);

   }

 

 

   configure_i2s_pins(0);

   configure_i2c_pins(I2C0_IDX);

   /* Init board clock */

   BOARD_ClockInit();

 

 

   installIntHandlers();

 

 

  

  GPIO_DRV_Init(switchPins, ledPins);

 

 

   configureWatchdog(5);

   WDOG_DRV_Refresh();

 

 

   printf("\r\n");

 

 

  

   if(watchdogReboot())

   {

      LOG_FATAL("System reboot due to watchdog\n");

   }

 

 

 

 

 

   //Periodically feed the watchdog

   uint32_t val = 0;

   while(true)

   {

      OSA_TimeDelay(1000);

 

 

      val = (~val) & 0x01;

      GPIO_HAL_WritePinOutput(PTE, 6, val);

 

 

      if(GPIO_HAL_ReadPinInput(PTA, 4) != 0)

      {

         printf("feed the dog\n");

         WDOG_DRV_Refresh();

      }

   }

   return;

}

Outcomes