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/LAUNCHXL-CC1310: Watchdog do not cause any reset

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310

Tool/software: TI-RTOS

Hi,

I want to use a Watchdog to reset my device. For Testing, I combined the uartecho and the watchdog example from the simplelink_cc13x0_sdk_1_30_00_06.

If I use a Watchdog callback like in the watchdog example, everything works as expected. But since I want to use the Watchdog for resetting, I switched removed the callback and set the resetMode to ON. Now I would expect that the Device performes a reset when the Watchdog expires, so I would see the Startup Message again. But nothing is happen.

This is the Code I used:

/*
 * Copyright (c) 2016, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/*
 *  ======== watchdog.c ========
 */
#include <unistd.h>
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>

/* TI-RTOS Header files */
#include <ti/drivers/PIN.h>
#include <ti/drivers/Watchdog.h>

/* Example/Board Header files */
#include "Board.h"

/* Global memory storage for a PIN_Config table */
static PIN_State ledPinState;
static PIN_State buttonPinState;

/* Pin driver handles */
static PIN_Handle ledPinHandle;
static PIN_Handle buttonPinHandle;

/*
 * Application LED pin configuration table:
 *   - Board_PIN_LED0 is initially off.
 */
PIN_Config ledPinTable[] = {
    Board_PIN_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};

/*
 * Application button pin configuration table:
 */
PIN_Config buttonPinTable[] = {
    Board_PIN_BUTTON0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_POSEDGE,
    PIN_TERMINATE
};

bool serviceFlag = true;
bool watchdogExpired = false;
Watchdog_Handle watchdogHandle;

/*
 *  ======== watchdogCallback ========
 *  Watchdog interrupt callback function.
 */
void watchdogCallback(uintptr_t unused)
{
    /* Clear watchdog interrupt flag */
    Watchdog_clear(watchdogHandle);

    watchdogExpired = true;
    Watchdog_setReload(watchdogHandle, 1500000);

    /* Insert timeout handling code here. */
}

/*
 *  ======== pinButtonFxn ========
 *  Callback function for the GPIO interrupt on Board_PIN_BUTTON0.
 */
void pinButtonFxn(PIN_Handle handle, PIN_Id pinId)
{
    /* Clear serviceFlag to stop continuously servicing the watchdog */
    serviceFlag = false;
}

/*
 *  ======== main ========
 */
void *mainThread(void *arg0)
{
    char        input;
    const char  echoPrompt[] = "Echoing characters:\r\n";
    UART_Handle uart;
    UART_Params uartParams;

    /* Call driver init functions */
//    GPIO_init();
    UART_init();



    /* Create a UART with data processing off. */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;

    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
        /* UART_open() failed */
        while (1);
    }

//    /* Turn on user LED */
//    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);

    UART_write(uart, echoPrompt, sizeof(echoPrompt));

//    while (1) {
//         UART_read(uart, &input, 1);
//         UART_write(uart, &input, 1);
//     }

    Watchdog_Params params;

    /* Call board init functions */
    Watchdog_init();
    UART_write(uart, "0\n", 2);
    /* Open LED pin */
    ledPinHandle = PIN_open(&ledPinState, ledPinTable);
    if(!ledPinHandle) {
        /* Error initializing board LED pin */
        while (1);
    }

    UART_write(uart, "1\n", 2);

    /* Turn OFF user LED */
    PIN_setOutputValue(ledPinHandle, Board_PIN_LED0, 0);

    /* Setup callback for button pin */
    buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
    if(!buttonPinHandle) {
        /* Error initializing button pins */
        while (1);
    }
    if (PIN_registerIntCb(buttonPinHandle, &pinButtonFxn) != 0) {
        /* Error registering button callback function */
        while (1);
    }
    PIN_setInterrupt(buttonPinHandle, Board_PIN_BUTTON0|PIN_IRQ_POSEDGE);

    /* Create and enable a Watchdog with resets disabled */
    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);
    }
    Watchdog_setReload(watchdogHandle, 1500000);

    UART_write(uart, "a\n", 2);

    /* Enter continous loop */
    while (true) {

        /* Service watchdog if serviceFlag is true */
        if (serviceFlag) {
            Watchdog_setReload(watchdogHandle, 1500000);
            //Watchdog_clear(watchdogHandle);
        }

        /* If watchdog expired since last started, turn ON LED */
        if (watchdogExpired) {
            UART_write(uart, "b\n", 2);
            PIN_setOutputValue(ledPinHandle, Board_PIN_LED0, 1);
            sleep(5);
            Watchdog_clear(watchdogHandle);
            serviceFlag = true;
            watchdogExpired = false;
            PIN_setOutputValue(ledPinHandle, Board_PIN_LED0, 0);
            UART_write(uart, "c\n", 2);
        }
    }
}

Alternatively, is there an other way to perform a reset? I tried SysCtrlSystemReset() and HapiResetDevice() but they just make the application stuck and don't do a reset.

  • Hi,

    thank you for posting a minimal and complete example. It works as expected. After pressing BUTTON0, serviceFlag is invalidated and Watchdog_setReload() is not called anymore. That leads to a reset after 2x1500000 Watchdog ticks (you might use Watchdog_convertMsToTicks() to make the code more readable).

    If you have the debugger attached, then after the reset, the CC1310 will halt in boot because it sees a clock signal at the JTAG port. Just disconnect the debugger before the reset.

  • Thx for the answer,

    I guess the debugger was the problem but I cannot be 100% sure right now because without the debugger I don't have the uart for debug messages.

    I tried to include the Watchdog into the Collector Example from the simplelink_1_30 but I'm getting linking errors.

    <Linking>

    undefined first referenced
    symbol in file
    --------- ----------------
    Watchdog_config C:/ti/simplelink_cc13x0_sdk_1_30_00_06/source/ti/drivers/lib/drivers_cc13x0.aem3<Watchdog.oem3>
    Watchdog_count C:/ti/simplelink_cc13x0_sdk_1_30_00_06/source/ti/drivers/lib/drivers_cc13x0.aem3<Watchdog.oem3>

    error #10234-D: unresolved symbols remain

    Is there something else I need to add to make the Watchdog work in the Collector Example?
  • Hi,
    the debugger isn't needed to read UART messages. You would just use a terminal application. On Windows, HTerm or TeraTerm for example. Regarding the colloector example, I'll assign this thread to somebody who is familiar with the TI 15.4 stack.

  • But when I put a cable into the launchpad, the debugger (on the board) is connected to the cc1310.

    But the bigger problem is that I'm not able to integrate the watchdog into the collector example because of linken errors. Do I have to activate the watchdog drivers in some way?

  • Hey Tobias,

    Try adding the watchdog.c driver to your project and rebuild your project. this driver can be found <SDK>/source/ti/drivers.

    ~Brocklobsta