This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/CC2640R2F: Watchdog functionality

Part Number: CC2640R2F
Other Parts Discussed in Thread: BLE-STACK, SIMPLELINK-CC2640R2-SDK

Tool/software: Code Composer Studio

Version information  CCS version: 7.1.0    TI-RTOS 2.20    TI BLE-Stack 3.00.00.22

I am trying to use the internal watchdog to reset my device, but I cannot get this functionality to use.

I have tried both the driver interface and the driver lib interface and even by setting necessary regisers in the controller.

I have read some threads in this forum and search on other sites but dont find the answer. In some places it states that the watchdog is exprimental but I guess that this means the driver layer.

When running with the debugger the callback is called every 5 seconds, but now reset because, as far as I understand, the reset functionality for soft reset is inhibited.

Without the debugger I dont see any reset.  have a LED flash at power up but does only see it once at the first power up. The functionality of the device works as it should (except that it should reset every 10th second)

I have also tried to call SysCtrlSystemReset() from the callback function but I this does not reset the device. Outside the callback it works

I guess that it is some small thing that I have forgot but what?

The code below. (main is calling HALInit() then HAL_WDT_Enable() and I never call the HAL_WDT_Kick() )


/* Handle for the watchdog */
static Watchdog_Handle HAL_WDT_Handle;


void HAL_Init()
{
  ...

  /* Call board init functions */
  Watchdog_init();

  ...

}

 

void HAL_WDT_Callback(uintptr_t unused)
{
  /* Clear watchdog interrupt flag */
  Watchdog_clear(HAL_WDT_Handle);
}

void HAL_WDT_Enable(void)
{
  Watchdog_Params params;
  uint32_t ticks;

  /* Create and enable a Watchdog with resets disabled */
  Watchdog_Params_init(&params);

  params.callbackFxn = (Watchdog_Callback)HAL_WDT_Callback;
  params.resetMode = Watchdog_RESET_ON;
// params.debugStallMode = Watchdog_DEBUG_STALL_ON;

  HAL_WDT_Handle = Watchdog_open(Board_WATCHDOG0, &params);
  if (HAL_WDT_Handle == NULL)
  {
    /* Error opening Watchdog */
    while (1);
  }

  ticks = Watchdog_convertMsToTicks(HAL_WDT_Handle, 5000);
  (void)Watchdog_setReload(HAL_WDT_Handle, ticks);
}

void HAL_WDT_Kick(void)
{
  Watchdog_clear(HAL_WDT_Handle);
}

Regards Örjan

  • Hello,

    Your post specified that you are using TI-RTOS 2.20 and TI BLE-Stack 3.00.00.22. Can you use SIMPLELINK-CC2640R2-SDK v1.30 or later? The TI RTOS is contained in the SDK and should not be changed from the supplied version.

    It is correct that the XDS110 will not allow the MCU to reset if it is attached. Can you confirm that "without the debugger" means you do not have the debugger attached? Can you pull the jumpers if you are using the LaunchPad?

    Best wishes
  • Hello

    This is the version we are using:  simplelink_cc2640r2_sdk_1_00_00_22 and we have not the possibility to updata now.
    I am not using the LaunchPad and when I say that the debugger is deconnected I mean that the j-tag connector is removed and the HW is powered from a power supply.

    Though, I have discoverd some things that I did not know about the application (I am not the only deveolper).
    The application enters low power mode between the advertisment and according to what I have read the WDT counter will the count slower, so 4 second will probably be around 1 hour :)

    I have changed into usnig the driverlib instead and after some, stupid, misstakse I finally got it up and running as I wanted. Below you will find the source code.
    And... yes I know that using a timer to kick the watchdog is not the best idéa, but for my solution its enough.

    I will leave as it is for now on but if I get some time left I will try again to use the driver layer and see if its working.

    Regards Ørjan 

    /*
     * @fn      HAL_WDT_Enable
     *
     * @brief   Enables the internal watch-dog for giving a reset after 4 seconds.
     *
     *          After two seconds the WDT will give an interrupt and start counting again and give a reset after the next
     *          two seconds.
     *          To prevent the reset in the second phase the timer interrupt must be cleared before it expires.
     *          Before the interrupt is generated the WDT is restarted by writing a new value into it
     *
     * @note    In order not to continue counting when the debugger is stopped the stall must be enabled.
     *
     * @param   None.
     *
     * @return  None.
     */
    void HAL_WDT_Enable(void)
    {
      /* The command below will cause the WDT counter stop counting when the debugger is stopped */
      /* TODO!! Should be removed in release code */
      WatchdogStallEnable();

      /* Load the counter value, enable reset functionality and start the WDT */
      WatchdogReloadSet(APP_CONFIG_WDT_TIMEOUT_TICKS);
      WatchdogResetEnable();
      WatchdogEnable();
    }


    /*
     * @fn      HAL_WDT_Disable
     *
     * @brief   Disables the internal watch-dog
     *
     * @param   None.
     *
     * @return  None.
     */
    void HAL_WDT_Disable(void)
    {
      WatchdogResetDisable();
    }


    /*
     * @fn      HAL_WDT_TimerStart
     *
     * @brief   Starts a software timer that will kick the watch-dog every third second.
     *
     * @param   None.
     *
     * @return  None.
     */
    void HAL_WDT_TimerStart(void)
    {
      Clock_Params clockParams;

      clockParams.arg = 0;
      Clock_Params_init(&clockParams);

      /* Construct ant start the WDT kicker that will reset the WDT every time it expires */
      Clock_construct(&HAL_WDT_Kick_Clock, HAL_WDT_Kick_SwiFxn, APP_CONFIG_WDT_KICKER_TIME_MS * (1000/Clock_tickPeriod), &clockParams);
      Clock_start(Clock_handle(&HAL_WDT_Kick_Clock));
    }

    /*
     * @fn      HAL_WDT_Kick_SwiFxn
     *
     * @brief   Callback function for the software timer that shall kick the watch-dog before it expires
     *
     * @param   dummy - A must parameter in timer call-backs. Not used.
     *
     * @return  None.
     */
    static void HAL_WDT_Kick_SwiFxn(UArg dummy)
    {
      /* Clear the WDT interrupt, must be done. See description in HAL_WDT_Enable() */
      WatchdogIntClear();

      /* Reload the WDT counter and restart the software timer */
      WatchdogReloadSet(APP_CONFIG_WDT_TIMEOUT_TICKS);
      Clock_start(Clock_handle(&HAL_WDT_Kick_Clock));
    }