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/CC2650: watchdog not working

Part Number: CC2650


Tool/software: TI-RTOS

I'm trying to add the watchdog functionality to a heavily modified sensortag example.

SW versions: BLE SDK 2_02_02_25, TI RTOS 2_21_01_08, BLE STACK 2-2-2 and CCS 7.4

In my board.c I have:

#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(Watchdog_config, ".const:Watchdog_config")
#pragma DATA_SECTION(watchdogCC26XXHWAttrs, ".const:watchdogCC26XXHWAttrs")
#endif

WatchdogCC26XX_Object watchdogCC26XXObjects[CC2650STK_WATCHDOGCOUNT];

const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs[CC2650STK_WATCHDOGCOUNT] = {
    {
        .baseAddr    = WDT_BASE,
        .intNum = INT_NMI_FAULT, /* INT_WDT_IRQ or INT_NMI_FAULT ?? */
        .reloadValue = 3000 /* Reload value in milliseconds */
    },
};

const Watchdog_Config Watchdog_config[] = {
    {
        .fxnTablePtr = &WatchdogCC26XX_fxnTable,
        .object      = &watchdogCC26XXObjects,  /* CC2650STK_WATCHDOG0 */
        .hwAttrs     = &watchdogCC26XXHWAttrs   /* CC2650STK_WATCHDOG0 */
    },
    {NULL, NULL, NULL},
};

const uint_least8_t Watchdog_count = CC2650STK_WATCHDOGCOUNT;

In my application:

#define WDT_MS      3000

void watchdog_callback(UArg handle){
    Watchdog_clear((Watchdog_Handle)handle);
}


void watchdogtimer_init(){
    Watchdog_Params wdParams;
    uint32_t tickValue;

    // open watchdog
    Watchdog_init();
    Watchdog_Params_init(&wdParams);

    wdParams.resetMode = Watchdog_RESET_ON;
    wdParams.debugStallMode = Watchdog_DEBUG_STALL_ON;
    wdParams.callbackFxn = watchdog_callback;
    wdtHandle = Watchdog_open(Board_WATCHDOG, &wdParams);   // CC2650STK_WATCHDOG0
    tickValue = Watchdog_convertMsToTicks(wdtHandle, WDT_MS);
    Watchdog_setReload(wdtHandle, tickValue);
}

in my main task init I successfully call:
watchdogtimer_init();

After 3 seconds (WDT_MS 3000) there'es a HW exception and the os is spinning in:

    /* spin here if no exception handler is plugged */
    while (Hwi_excHandlerFunc == NULL) {
    ;
    }

I have experimented with stuff that I've found in e2e but none have worked for me:

  • If I understand correctly I need to call Watchdog_clear(wdtHandle) within the 3000ms timeout to keep the device alive? In that case I can make it work. When I then induce a HW exception, triggered by an external button with a filthy recursive function then the device restarts automatically.
    I'm not sure if that is the correct way though.
  • Sven,

    The watchdog functions in such a way that the first timeout does not trigger a reset, while the second timeout (IF the first left the watchdog un-handled) will reset the device.

    Are you calling Watchdog_clear() in a callback function? This clears the flag and prevents the second timeout from resetting the device.

    See the driver Doxygen documentation here for a more comprehensive explanation.

    BR,

    Seong

  • Thanks for the reply Craig, but I'm still quite confused.

    I understand it like this:

    Because of the double time-out behavior it is possible to call watchdog_clear from within the watchdog callback function. Doing so will prevent a reset. If there is a severe SW issue then this clear function will not be called and the device will reset.

    This is however not the behavior I'm seeing. As shown in my code above I do use this callback function with a watchdog_clear() but after the reload value my device either goes into a HW exception or resets immediately.

    I can get around it by calling an additional watchdog_clear() periodically within the reload period but I'm not sure if this will always work as intended.

  • Sven,

    An easy thing to try is to enable debug features in the .cfg file.

    - If you have a separate kernel project (e.g. the TI Driver examples do this)
    Use the Debug kernel project (instead of the Release) kernel project. Please refer to the SimpleLink User Guide for details on how to change the kernel project.

    - If this is a BLE example that has the .cfg in the application project,
    Please un-exclude the ble_debug.cfg file and exclude the ble_release.cfg file. Rebuild and run and you should get more information.

    - if it's neither of the above, do a differ of the debug.cfg and release.cfg files and make the corresponding changes in your .cfg. Note: the footprint will increase due to the extra debug features.

    BR,
    Seong
  • HI Seong,

    The additional debug features look like a great way to keep me busy for a long time but unfortunately the footprint is too large. I must find another way.

    It looks actually as if the callback function is never called. The callback is definitely not fired. Could there be a specific reason for this?

  • Hi,

    I suggest you experiment with the WDT example in the SDK and then implement it in your application.

    Also note that watchdog is disabled during standby and therefore if the watchdog is required in your application as well as low power, then use an external one.

    regards,