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.

RTOS/CC2640: "Watchdog_open(...)" causes reset in BLE stack 2.2.1

Part Number: CC2640
Other Parts Discussed in Thread: CC2650,

Tool/software: TI-RTOS

Hi,

I am trying to implement watchdog timer in Stack 2.2.1

In short, the line "Watchdog_open(...)" causes device to reboot/reset...

Any input will be appreciated!!!

In details,

Per the docs (file:///C:/ti/tirtos_cc13xx_cc26xx_2_20_01_08/products/tidrivers_cc13xx_cc26xx_2_20_01_10/docs/doxygen/html/_watchdog_c_c26_x_x_8h.html), using the below in the application:

#include <ti/drivers/watchdog.h>
#include <ti/drivers/watchdog/WatchdogCC26XX.h>
#include <driverlib/sys_ctrl.h>
//------------------------------------------------------------

Watchdog_Handle handle;
Watchdog_Params params;
uint32_t tickValue;

void watchdogCallback(UArg handle);

void WatchdogInit() {
    Watchdog_Params_init(&params);

    params.callbackFxn = watchdogCallback;

    //these were not in the driver example, tried with and without...
    //params.resetMode      = Watchdog_RESET_ON;
    //params.debugStallMode = Watchdog_DEBUG_STALL_ON;

    //this line causes a reboot...
    handle = Watchdog_open(Board_WATCHDOG, &params);

    //5 sec
    tickValue = Watchdog_convertMsToTicks(handle, 5000);
    Watchdog_setReload(handle, tickValue);
}

void watchdogCallback(UArg handle){
    Xpert_Tag_Debug("watchdogCallback...");
    //SysCtrlSystemReset();
}

//app will be calling Watchdog_setReload() to push watchdog as long as things are working as expected

//----------------------------------------------------------------------------------------------------------------------------------------------

in board H file:

#define Board_WATCHDOG                CC2650_WATCHDOG0
    typedef enum CC2650_WatchdogName {
        CC2650_WATCHDOG0 = 0,
        CC2650_WATCHDOGCOUNT,
    } CC2650_WatchdogName;

//----------------------------------------------------------------------------------------------------------------------------------------------

in board c file:

/*
*  ========================= Watchdog begin ====================================
*/
#include <ti/drivers/Watchdog.h>
#include <ti/drivers/watchdog/WatchdogCC26XX.h>

WatchdogCC26XX_Object watchdogCC26XXObjects[CC2650_WATCHDOGCOUNT];

const WatchdogCC26XX_HWAttrs watchdogCC26XXHwAttrs[] = {
    {
        .baseAddr = WDT_BASE,
        .intNum = INT_WDT_IRQ,
    }
};

const Watchdog_Config Watchdog_config[] = {
    { &WatchdogCC26XX_fxnTable, &watchdogCC26XXObjects[0], &watchdogCC26XXHwAttrs[0] },
    { NULL, NULL, NULL },
};
/*
*  ========================= Watchdog end ====================================
*/

  • Hi Sy10,

    Just to be clear are you using a CC2650? Your code looks like it is for a CC2650 but you have your thread titled CC2640.

    To answer your question, it looks like you are missing a call to the Watchdog_init() function before you initialize the parameters.

    As stated in the documentation, the Watchdog driver must be initialized by calling Watchdog_init(), before any other Watchdog APIs can be called. 

    This is an example of how the Watchdog should be setup:

    Watchdog_Params params;
    Watchdog_Handle watchdog;
    Watchdog_init();
    Watchdog_Params_init(&params);
    params.resetMode = Watchdog_RESET_ON;
    params.callbackFxn = UserCallbackFxn;
    watchdog = Watchdog_open(Board_WATCHDOG, &params);
    if (watchdog == NULL) {
        `Error opening watchdog`
    }

    -Sy Su

  • Yes, correct about Watchdog_init();

    After reading driver docs, I had added this in and was same result.

    I am using 2640, but is not the driver the same 2640 vs 2650? - "WatchdogCC26XX"

    I know, there are some "2650" typedefs but other 2650 drivers works on 2640 the same way.

  • Hi Sy10,

    Yes you are correct on that.

    When running your code, does it cause a reset immediately after calling Watchdog_open(), or does it reach the callback function first? Set a breakpoint in the callback to see if it reaches it.

    Based on the documentation, Watchdog_clear() should be called regularly to reload the counter to restart the timeout period and avoid the Watchdog interrupt from being triggered. If Watchdog_clear() is missed and the Watchdog timer is allowed to timeout, the user-defined callback function is called. In this function, the user may do whatever is appropriate for the application.

    Since you don't have any Watchdog_clear() function calls, it should be reaching the callback.

    This thread should also give you some insight: 

    RTOS/CC2650: Watchdog not working properly - Bluetooth forum - Bluetooth®︎ - TI E2E support forums

    e2e.ti.com
    Part Number: CC2650 Tool/software: TI-RTOS hi, hi, I am watchdog feature and it is working in some weird fashion, but my problem is like if i have set the watchdog

    -Sy Su

  • Thanks for comment. I just tried and I am not getting to the callback function - it resets right after Watchdog_open

    I will look into the other thread you sent, hopefully it has some answers for me, will keep this thread updated.

    Thank you
  • still have not found a solution to enabling watch dog timer in stack 2.2.1...