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/CC2640R2F: Watchdog does not make reset. Callback called but not executed

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

Tool/software: TI-RTOS

Hi!
I want to implemet Watchdog inside SimplePeripheral OAD on-chip for
CC2640. I initalize Watchdog in SimplePeripheral_taskFxn, before
endless cycle, like this (wdParams and wdHandle are global variables
in simple_peripheral_oad_onchip.c):

    //init Watchdog
    Watchdog_init();
    Watchdog_Params_init(&wdParams);
    wdParams.resetMode = Watchdog_RESET_ON;
    wdParams.debugStallMode = Watchdog_DEBUG_STALL_ON;
    wdParams.callbackFxn = (Watchdog_Callback) wdCallback;
    wdHandle = Watchdog_open(Board_WATCHDOG0, &wdParams);

Here is my callback function:

void wdCallback(uintptr_t watchdogHandle)
{
    toggleLed(); //100ms duration
    Watchdog_clear(wdHandle);
}

Here are objects in my board file:

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

WatchdogCC26XX_Object watchdogCC26XXObjects[GBA_BOARD_WATCHDOGCOUNT];

const WatchdogCC26XX_HWAttrs watchdogCC26XXHWAttrs

[GBA_BOARD_WATCHDOGCOUNT] = {
    {
        .baseAddr    = WDT_BASE,
        .reloadValue = 1000, /* Reload value in milliseconds */
    },
};

const Watchdog_Config Watchdog_config[GBA_BOARD_WATCHDOGCOUNT] = {
    {
        .fxnTablePtr = &WatchdogCC26XX_fxnTable,
        .object      = &watchdogCC26XXObjects[GBA_BOARD_WATCHDOG0],
        .hwAttrs     = &watchdogCC26XXHWAttrs[GBA_BOARD_WATCHDOG0]
    },
};

const uint_least8_t Watchdog_count = GBA_BOARD_WATCHDOGCOUNT;

When I run this code my LED doesn't toggle. If I put break point
inside wdCallback when toggleLed() not commented, then debugger show
this error after clicking resume button :

"Can't Run Target CPU: (Error -2134 @ 0x0) Unable to control device
execution state."

If toggleLed() is commented, then by clicking resume button in the
debugger every time I fall into break point into wdCallback and see
no errors.
If I remove callback function from wdParams, reset does not occur (debug probe was removed from my custom board).
My goal is to make reset after timeout if Watchdog_RESET_ON enabled.
What am I doing wrong? My SDK version is 3.10.0.15.

  • Hi Andrei,

    Assigning one of our experts to review.

  • Hi Andrei,

    1) Can you move the initialization to main() or the init function in simple_peripheral.c?

    2) Can you post your implementation in toggleLed()?

  • Hi Andrei,

    The watchdog example program calls the Watchdog_clear(wdHandle); at the callback. This is just so you can try the watchdog example program again and again. But at actual application this is not right.

    To test that your watchdog reset is working remove the Watchdog_clear(wdHandle); at the callback. Device reset will occur after 2x timeout.

    -kel

  • Thanks for reply!


    1) I moved initialization to main() but this does not help. Also I removed callback from wdParams.

    2) This implementation works fine in the other parts of application:

    void toggleLed(void){
        PIN_open(&sbpLedState, sbpLedPins);
        PIN_Id activeLed;
        activeLed = Board_LED;
        PIN_setOutputValue(&sbpLedState, activeLed, !PIN_getOutputValue(activeLed));
        Task_sleep(10000);
        PIN_setOutputValue(&sbpLedState, activeLed, !PIN_getOutputValue(activeLed));
        Task_sleep(10000);
        // Close pins after using
        PIN_close(&sbpLedState);
    }

  • Thanks for reply!

    I've tried watchdog without callback in wdParams but this also doesn't work. Watchdog example from SDK works fine on my LAUNCHXL board. Is it possible for problem to be in board files changings for my custom board? For watchdog I've just changed all CC2640R2_LAUNCHXL prefixes to my custom board name.

  • Hi Andrei,

    What CC2640R2F SDK version are you using? For learning purposes I suggest you try implement watchdog at simple peripheral using the Launchpad. Flash the simple peripheral to Launchpad, do not debug. This will reset the device at 2x timeout.

    Call this at Simple Periheral Init

    Watchdog_Handle watchdogHandle;
    Watchdog_Params params;

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

    /* Open a Watchdog driver instance */

    Watchdog_Params_init(&params);
    params.callbackFxn = (Watchdog_Callback) watchdogCallback;
    params.resetMode = Watchdog_RESET_ON;

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

    void watchdogCallback(uintptr_t watchdogHandle)
    {
    //led on off indicator
    }

    put while loop at GAPROLE_ADVERTISING to make sure it hangs.

    -kel

  • Hi Andrei,

    Did you figure it out?

    I will close this thread due to inactivity.

  • I have removed POWER_SAVING predefined symbol from user app compiler predefined symbols and chip started to reset. What is the proper way to use watchdog with POWER_SAVING?

  • Hi Andrei,

    You can use POWER_SAVING, but remember that the watchdog clock is effectively paused when the device is standby mode. 

  • Hi,

    The Watchdog Reset works with POWER_SAVING predefine set. I just tested it with my watchdog test code. If you test watchdog with Launchpad and powered using USB, it will not work properly, from what I know this is cause by halt in boot issue. So, to test watchdog using Launchpad you need to remove all jumpers except the led jumpers and power it externally. 

    With this watchdog test code below the CC2640R2F will do  a watchdog reset every 26 seconds. The Watchdog Timeout is set to default 1 seconds. The reason for the watchdog reset every 26 seconds is that after advertising it goes to standby mode.

    I am using SDKv2.40

    Here is my test code.

    Watchdog_app.c

    void WatchdogApp__Callback(uintptr_t unused)
    {
        Led_Off(Board_PIN_LED0);
    }
    
    void WatchdogApp__Init(void)
    {
        Watchdog_Params params;    
            
        Watchdog_init();
        
        Watchdog_Params_init(&params);
        params.callbackFxn = (Watchdog_Callback)WatchdogApp__Callback;
        params.resetMode = Watchdog_RESET_ON;
        WatchdogHandle = Watchdog_open(Board_WATCHDOG0, &params);
            
        if (WatchdogHandle == NULL) {
            /* Error opening Watchdog */
            while (1);
        }
    }

    simple_peripheral.c SimplePeripheral_init()

      Led_Init();
      Led_On(Board_PIN_LED0);
      WatchdogApp__Init();

    -kel