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.

PROCESSOR-SDK-AM64X: Watchdog

Part Number: PROCESSOR-SDK-AM64X

Hi,

Processor Type: GP Processor

SDK Version: 08_06_00_43

We have a custom board, and the watchdog is not working.

The example watchdog in SDK 08_06_00_43 doesn't seem to trigger.

Is there a problem with the example watchdog code or is there a problem with the SDK?

Thank you,

  • Hello,

    Which SDK are you using, Linux or MCU+? This will help us assign to the correct expert.

    Best Regards,

    Anshu

  • Thanks. The thread has been assigned. Please allow some time for a response.

  • Hello Christopher Holland,

    How are you confirming that the watchdog is not triggered ?

    Did you keep the break point in Watchdog interrupted, and it is not hitting ?

    Regards,

    Anil.

  • Hi Swargam,

    I resolved the issue.

    For some reason or another, I had to clear the watchdog after I enabled it.

    I think it might have been previously set or something.

    The same issue happens when power is NOT disconnected.

    The watchdog will stay triggered and will not trigger again, unless it is cleared.

    Thanks,

  • Oh, I thought I fixed it, but apparently it's not working.

    I originally thought it had something to do with "petting" or clearing the watchdog after it was initialized, but apparently, that is not correct. 

    After much troubleshooting, it appears as though the Watchdog must be > 1000 mS. Anything under 1000 mS will not cause the interrupt.

    There does not seem to be a minimum.  

  • Hello Christopher Holland,

    Mostly SOC can use two frequencies for watchdog clock one is 32KHz and another one 25MHz.

    Please look at more clock selections for watchdog from the link below .

    https://dev.ti.com/sysconfig/#/config/?args=--product%20%2Fmnt%2Ftirex-content%2Fsitara_ctt_1_1_1%2F.metadata%2Fproduct.json%20--device%20AM64x%20--part%20Default%20--package%20ALV%20--context%20system

    So, in our MCU+SDK by default we are feeding a 32552KHz clock signal to Watchdog and for this you can only configure expired time in between from >251msec to 1031sec.

    If you feed a 25MHz clock signal, then you can configure to the expired time expire between >0.32msec to 1.34 sec.

    So, choose the WDT clock based on your requirements.

    I am sharing the same analysis document for your reference.

    Any other clock selections we don't support from system cfg. So, you need to take care manually.

    Actually, the code below can be helpful to how to configure the watchdog manually.

    In the code, you need to just change WDT clock frequency to 25MHz for your requirement.

    status = SOC_moduleSetClockFrequency( TISCI_DEV_MCU_RTI0,TISCI_DEV_MCU_RTI0_RTI_CLK,25000000);
        DebugP_assertNoLog(status == SystemP_SUCCESS);

    /*
     *  Copyright (C) 2021 Texas Instruments Incorporated
     *
     *  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.
     */
    
    #include <stdio.h>
    #include <kernel/dpl/DebugP.h>
    #include "ti_drivers_config.h"
    #include "ti_drivers_open_close.h"
    #include "ti_board_open_close.h"
    #include <drivers/watchdog.h>
    
    /*
     * This is an empty project provided for all cores present in the device.
     * User can use this project to start their application by adding more SysConfig modules.
     *
     * This application does driver and board init and just prints the pass string on the console.
     * In case of the main core, the print is redirected to the UART console.
     * For all other cores, CCS prints are used.
     */
    
    /*
     * watchdog
     */
    /* watchdog atrributes */
    
    
    
    void watchdog_interrupt_main(void);
    void watchdogCallback(void *arg);
    void Drivers_watchdogClose(void);
    void Drivers_watchdogOpen(uint32_t mode);
    
    
    #define CONFIG_WATCHDOG_NUM_INSTANCES (1U)
    #define CONFIG_WDT0  (0U)
    #define NUM_OF_ITERATIONS (10U)
    #define INIT_CONFIG       0U
    #define RUN_TIME_CONFIG   1U
    
    #define CONFIG_WDT_INT_NUM (16U + CSLR_MCU_M4FSS0_CORE0_NVIC_MCU_RTI0_INTR_WWD_0)
    
    
    volatile uint32_t   gWatchdogInt = 0;
    uint32_t gWatchdogConfigNum = CONFIG_WATCHDOG_NUM_INSTANCES;
    
    
    /* watchdog Driver handles */
    Watchdog_Handle gWatchdogHandle[CONFIG_WATCHDOG_NUM_INSTANCES];
    
    /* watchdog Driver Parameters */
    Watchdog_Params gWatchdogParams[CONFIG_WATCHDOG_NUM_INSTANCES] =
    {
        {
            .callbackFxn        = NULL,
            .callbackFxnArgs    = NULL,
            .resetMode          = Watchdog_RESET_OFF,
            .debugStallMode     = Watchdog_DEBUG_STALL_ON,
            .windowSize         = Watchdog_WINDOW_100_PERCENT,
            .expirationTime     = 10000,/* Here we need to configure M4F expiration Time in msec*/
        },
    };
    
    
    
    static Watchdog_HwAttrs gWatchdogHwAttrs[CONFIG_WATCHDOG_NUM_INSTANCES] =
    {
        {
            .instance        = WATCHDOG_INST_ID_MCU_RTI0,
            .baseAddr        = CSL_MCU_RTI0_CFG_BASE,/*0x84880000, Here we need to convert CSL_MCU_RTI0_CFG_BASE address to local M4F Address space*/
            .wdtClkFrequency = 32552U,
        },
    };
    /* Watchdog objects - initialized by the driver */
    Watchdog_MCB gWatchdogObjects[CONFIG_WATCHDOG_NUM_INSTANCES];
    
    /* Watchdog driver configuration */
    Watchdog_Config gWatchdogConfig[CONFIG_WATCHDOG_NUM_INSTANCES] =
    {
        {
            .object = &gWatchdogObjects[CONFIG_WDT0],
            .hwAttrs = &gWatchdogHwAttrs[CONFIG_WDT0]
        },
    };
    
    
    void empty_main(void *args)
    {
        /* Open drivers to open the UART driver for console */
        Drivers_open();
        Board_driversOpen();
        int32_t status;
        uint32_t Baseaddress;
    
    
        status = SOC_moduleClockEnable(TISCI_DEV_MCU_RTI0, 1);
        DebugP_assertNoLog(status == SystemP_SUCCESS);
    
        status = SOC_moduleSetClockFrequency( TISCI_DEV_MCU_RTI0,TISCI_DEV_MCU_RTI0_RTI_CLK,32552);
        DebugP_assertNoLog(status == SystemP_SUCCESS);
    
        Baseaddress = (uint32_t) AddrTranslateP_getLocalAddr(CSL_MCU_RTI0_CFG_BASE);
        gWatchdogHwAttrs[CONFIG_WATCHDOG_NUM_INSTANCES - 1U].baseAddr        = Baseaddress;
    
        DebugP_log("Watchdog interrupt Mode Test Started ...\r\n");
    
    
        //Drivers_watchdogOpen(INIT_CONFIG);
        Drivers_watchdogOpen(RUN_TIME_CONFIG);
    
        watchdog_interrupt_main();
    
    }
    
    
    void watchdog_interrupt_main(void)
    {
    
    
        HwiP_Params             hwiPrms;
        int32_t                 status = SystemP_SUCCESS;
        static HwiP_Object       gRtiHwiObject;
        /* Register interrupt */
        HwiP_Params_init(&hwiPrms);
        hwiPrms.intNum      = CONFIG_WDT_INT_NUM ;
        hwiPrms.callback    = &watchdogCallback;
    
    
        status              = HwiP_construct(&gRtiHwiObject, &hwiPrms);
        DebugP_assert(status == SystemP_SUCCESS);
    
    
        DebugP_log("Watchdog interrupt Mode Test Started ...\r\n");
    
        while (gWatchdogInt < NUM_OF_ITERATIONS);
    
        DebugP_log("Watchdog Driver Interrupt received\r\n");
    
        DebugP_log("All tests have passed!!\r\n");
    
        Board_driversClose();
    
        Drivers_close();
    
        Drivers_watchdogClose();
    
    
    }
    
    
    void watchdogCallback(void *arg)
    {
        if (gWatchdogInt < NUM_OF_ITERATIONS)
        {
            HwiP_clearInt(CONFIG_WDT_INT_NUM);
            Watchdog_clear(gWatchdogHandle[CONFIG_WDT0]);
            gWatchdogInt++;
        }
        return;
    }
    
    
    void Drivers_watchdogOpen(uint32_t mode)
    {
        uint32_t instCnt;
        int32_t  status = SystemP_SUCCESS;
    
        for(instCnt = 0U; instCnt < CONFIG_WATCHDOG_NUM_INSTANCES; instCnt++)
        {
            gWatchdogHandle[instCnt] = NULL;   /* Init to NULL so that we can exit gracefully */
        }
    
        /* Open all instances */
        for(instCnt = 0U; instCnt < CONFIG_WATCHDOG_NUM_INSTANCES; instCnt++)
        {
            if(mode == INIT_CONFIG)
            {
                /* Call Watchdog_open() with Initialization timeout if mode is INIT_CONFIG*/
                gWatchdogParams[instCnt].expirationTime = 1000;
            }
            gWatchdogHandle[instCnt] = Watchdog_open(instCnt, &gWatchdogParams[instCnt]);
            if(NULL == gWatchdogHandle[instCnt])
            {
                DebugP_logError("Watchdog open failed for instance %d !!!\r\n", instCnt);
                status = SystemP_FAILURE;
                break;
            }
        }
    
        if(SystemP_FAILURE == status)
        {
            Drivers_watchdogClose();   /* Exit gracefully */
        }
    
        return;
    
    }
    
    void Drivers_watchdogClose(void)
    {
        uint32_t instCnt;
    
        /* Close all instances that are open */
        for(instCnt = 0U; instCnt < CONFIG_WATCHDOG_NUM_INSTANCES; instCnt++)
        {
            if(gWatchdogHandle[instCnt] != NULL)
            {
                Watchdog_close(gWatchdogHandle[instCnt]);
                gWatchdogHandle[instCnt] = NULL;
            }
        }
    
        return;
    }
    
    

    For testing purpose try to configure expired time to 520msec and see if you are able to get the watchdog interrupt or not .Since, this expire time should work as per our analysis .

    Regards,

    Anil.