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.

CC2340R5: CC2340R53 Watchdog Callback Function

Part Number: CC2340R5


Tool/software:

Hello,

I was wondering if the CC2340R53 supports watchdog callback functions at all? I looked through WatchdogLPF3.c and it didn't look like anything could be configured in that way. Does the WatchdogLPF3 generate some type of interrupt that a callback function could be attached to at least? I am using version 8.20.00.119 of the simplelink-lowpower-f3-sdk.

Thanks

  • Hello Alexander,

    I hope you are doing well, our CC2340R5 supports the watchdog callback:

    void UserCallbackFxn(Watchdog_Handle handle)
    {
        printf("Watchdog timer triggered!\n");
        releaseResources();
    }
    ...
    Watchdog_Params params;
    Watchdog_Handle watchdogHandle;
    Watchdog_init();
    Watchdog_Params_init(&params);
    params.resetMode = Watchdog_RESET_ON;
    params.callbackFxn = (Watchdog_Callback) UserCallbackFxn;
    watchdogHandle = Watchdog_open(CONFIG_WATCHDOG0, &params);
    if (watchdogHandle == NULL) {
       // Error opening Watchdog
       while (1);
    }

    You can reference the driver section (and click on the "examples" button) to see more detail about the driver.

    Thanks,
    Alex F

  • Hello Alex,

    Thanks for the response!

    When I look through the simplelink sdk code in WatchdogLPF3.c, I don't see any implementation where the resetMode and callbackFxn parameters are used. I see that these are available in the generic Watchdog api because other devices do support this, and in their device specific watchdog drivers do use these parameters in the implementations.

    For example, here is the function for the LPF3 implementation of Watchdog_open where I can see that it only sets the debugStallMode:

    Watchdog_Handle WatchdogLPF3_open(Watchdog_Handle handle, Watchdog_Params *params)
    {
        uintptr_t key;
        WatchdogLPF3_Object *object;
    
        /* get the pointer to the object and hwAttrs */
        object = handle->object;
    
        /* disable preemption while checking if the Watchdog is open. */
        key = HwiP_disable();
    
        /* Check if the Watchdog is open already with the hwAttrs */
        if (object->isOpen == true)
        {
            HwiP_restore(key);
            return (NULL);
        }
    
        object->isOpen = true;
        HwiP_restore(key);
    
        /* initialize the Watchdog object */
        object->debugStallMode = params->debugStallMode;
    
        /* initialize the watchdog hardware */
        WatchdogLPF3_initHw(handle);
    
        /* return handle of the Watchdog object */
        return (handle);
    }

    While in a different watchdog driver implementation, (from WatchdogCC26XX.c in the sdk for the CC2640R2), you can see that it does set the resetMode and sets the callback function:

    Watchdog_Handle WatchdogCC26XX_open(Watchdog_Handle handle, Watchdog_Params *params)
    {
        unsigned int                   key;
        HwiP_Params                     hwiParams;
        WatchdogCC26XX_Object         *object;
    
        /* get the pointer to the object and hwAttrs */
        object = handle->object;
    
        /* disable preemption while checking if the WatchDog is open. */
        key = HwiP_disable();
    
        /* Check if the Watchdog is open already with the HWAttrs */
        if (object->isOpen == true) {
            HwiP_restore(key);
            DebugP_log1("Watchdog: Handle %x already in use.", (uintptr_t)handle);
            return (NULL);
        }
    
        object->isOpen = true;
        HwiP_restore(key);
    
        /* initialize the Watchdog object */
        object->debugStallMode = params->debugStallMode;
        object->resetMode      = params->resetMode;
    
        /* Construct Hwi object for Watchdog */
        HwiP_Params_init(&hwiParams);
        hwiParams.arg = (uintptr_t)handle;
    
        /* setup callback function if defined */
        if (params->callbackFxn != NULL) {
            HwiP_plug(INT_NMI_FAULT, (void *)params->callbackFxn);
        }
    
        /* initialize the watchdog hardware */
        WatchdogCC26XX_initHw(handle);
    
        DebugP_log1("Watchdog: handle %x opened" ,(uintptr_t)handle);
    
        /* return handle of the Watchdog object */
        return (handle);
    }

    I have not found any alternative location that the simplelink f3 sdk could possibly set this value. Am I missing something in your explanation? My watchdog implementation that I currently have does reset the device, but the callback is never called.

  • Hello Alexander,

    I do see that Callback is an option with the CC2340R5 callback:

    My question here is now about resetMode, we have ways of reading how the device has resettled or shutdown->wakeup (ie power register notify feature, what is the purpose of using this in your case?

    Thanks,
    Alex F

  • This documentation that is being cited from the driver docs seems to be for the generic watchdog interface that is meant to be shared between devices of the family. I was more wondering about the capabilities of the WatchdogLPF3, not just the generic Watchdog interface. 

    This did help lead me to finding the docs for the LPF3 Watchdog driver, which did say that callback function and resetMode are not supported by this driver. The device specific driver documentation can be found here in the sdk: simplelink_lowpower_f3_sdk_8_20_00_119/docs/drivers/doxygen/html/_watchdog_l_p_f3_8h.html