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.

watchdog not resetting on beaglebone

Hi everyone,

I am using watchdog timer 1 on beaglebone using starterware 6. I have made just made a change in the demo program "wdtReset.c". I have removed all "uartstdio" things from the code and testing the reset process by blink of an LED on the board.

Q1. The problem is that the LED blinks once in the very first run of the code. After that, watch dog timer is not resetting the host processor. The code is copied below:


#include "gpio_v2.h"
#include "watchdog.h"
#include "hw_types.h"
#include "soc_AM335x.h"
#include "uartStdio.h"
#include "beaglebone.h"
#include "hw_cm_per.h"
#include "hw_cm_wkup.h"
#include "hw_control_AM335x.h"
/******************************************************************************
**                      INTERNAL MACRO DEFINITIONS
*******************************************************************************/
#define INITIAL_COUNT_VALUE          (0xFFFE0000u)
#define RELOAD_COUNT_VALUE           (0xFFFE0000u)
#define GPIO_INSTANCE_ADDRESS           (SOC_GPIO_1_REGS)
#define GPIO_INSTANCE_PIN_NUMBER        (23)

/******************************************************************************
**                      INTERNAL FUNCTION PROTOTYPES
*******************************************************************************/
/******************************************************************************
**                      INTERNAL VARIABLE DEFINITIONS
*******************************************************************************/


/******************************************************************************
**                          FUNCTION DEFINITIONS
*******************************************************************************/
/*
** This function will perform the necessary initialization for
** the Watchdog Timer.
**
*/
void GPIOPinMuxSetup(unsigned int pinNo)
{
    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_GPMC_AD(pinNo)) =
        (CONTROL_CONF_GPMC_AD_CONF_GPMC_AD_SLEWCTRL |     /* Slew rate slow */
        CONTROL_CONF_GPMC_AD_CONF_GPMC_AD_RXACTIVE |    /* Receiver enabled */
        (CONTROL_CONF_GPMC_AD_CONF_GPMC_AD_PUDEN & (~CONTROL_CONF_GPMC_AD_CONF_GPMC_AD_PUDEN)) | /* PU_PD enabled */
        (CONTROL_CONF_GPMC_AD_CONF_GPMC_AD_PUTYPESEL & (~CONTROL_CONF_GPMC_AD_CONF_GPMC_AD_PUTYPESEL)) | /* PD */
        (CONTROL_CONF_MUXMODE(7))    /* Select mode 7 */
        );
}

void Delay(volatile unsigned int count)
{
    while(count--);
}
void configGPIO(void)
{
    /* Enabling functional clocks for GPIO1 instance. */
    GPIO1ModuleClkConfig();

    /* Selecting GPIO1[23] pin for use. */
    GPIOPinMuxSetup(GPIO_INSTANCE_PIN_NUMBER);

    /* Enabling the GPIO module. */
    GPIOModuleEnable(GPIO_INSTANCE_ADDRESS);

    /* Resetting the GPIO module. */
    GPIOModuleReset(GPIO_INSTANCE_ADDRESS);

    /* Setting the GPIO pin as an output pin. */
    GPIODirModeSet(GPIO_INSTANCE_ADDRESS,
                   GPIO_INSTANCE_PIN_NUMBER,
                   GPIO_DIR_OUTPUT);
}

static void WatchdogTimerSetUp(void)
{
    /* Configure and enable the pre-scaler clock */
    WatchdogTimerPreScalerClkEnable(SOC_WDT_1_REGS, WDT_PRESCALER_CLK_DIV_1);

    /* Set the count value into the counter register */
    WatchdogTimerCounterSet(SOC_WDT_1_REGS, INITIAL_COUNT_VALUE);

    /* Set the reload value into the load register */
    WatchdogTimerReloadSet(SOC_WDT_1_REGS, RELOAD_COUNT_VALUE);
}

int main(void)
{
    unsigned int triggerValue = 0;

    configGPIO();

    /* Enable the WDT clocks */
    WatchdogTimer1ModuleClkConfig();

    /* Reset the Watchdog Timer */
    WatchdogTimerReset(SOC_WDT_1_REGS);

    /* Disable the Watchdog timer */
    WatchdogTimerDisable(SOC_WDT_1_REGS);

    /* Perform the initial settings for the Watchdog Timer */
    WatchdogTimerSetUp();

    /* Driving a logic HIGH on the GPIO pin. */
    GPIOPinWrite(GPIO_INSTANCE_ADDRESS,
                 GPIO_INSTANCE_PIN_NUMBER,
                 GPIO_PIN_HIGH);

    Delay(0x3FFFF);

    /* Driving a logic LOW on the GPIO pin. */
    GPIOPinWrite(GPIO_INSTANCE_ADDRESS,
                 GPIO_INSTANCE_PIN_NUMBER,
                 GPIO_PIN_LOW);

    printf("LED will light up again after about 4 sec\n");


    /* Enable the Watchdog Timer */
    WatchdogTimerEnable(SOC_WDT_1_REGS);


    while(1);


}

Q.2. Can somebody tell me how to insert inline assembly in the code....sppose I use watchdog dealy feature (not reset one), then how to write something which goes like this:

void wdtDelayIsr(void)

.asm:   mov pc, #main    ; reset program counter

OR

.asm  B main                  ; branch to the main() function

}

-- Thanks in advance!!

regards,

Pankaj