watchdog reset not getting back to main

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

watchdog reset not getting back to main

684 Views
kalden_srcinc
Contributor IV

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;

}

Labels (1)
0 Kudos
2 Replies

410 Views
kalden_srcinc
Contributor IV

It looks like SW3 is connected to a pin which is mapped to EZPort_CS by default.  I'm guessing that after watchdog reset, holding the button actually tells the MCU to boot in EZ port mode since the pin mux hasn't been configured yet.

0 Kudos

410 Views
kalden_srcinc
Contributor IV

Turns out, this problem only happens if I'm holding down the SW3 button on the board.  If change my main function to never feed the dog, things reset and work as expected.  If I hold down the SW3 button, the next time the watchdog triggers it never comes back.  I'm not sure why GPIO would impact the watch dog though.

0 Kudos