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.

WDFLAG not set after Watchdog Reset

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE

Hi,

Target: TMS320F28335 Delfino Microcontroller      Emulator: XDS100v2    IDE: Code Composer 5.5

Application Background: In this device we run a compressor controller application that interfaces to a customer board over CAN bus and process commands (i.e., speed up, slow down, etc). The application is all working fine.

I was given the task to add the proper enable and kick the watchdog to provide us with a safe reset in case the application hangs.  I have added the code to enable and kick the watchdog at an adequate frequency to avoid a watchdog reset while the application is running properly.  I also have code in place so that I can command the application to stop kicking the dog and let it expire.  When I do this I set a GPIO to high so that I can monitor this command with the scope. Then ~280msec later (as expected with the 30MHz oscillator / 512 / 64) the watchdog reset the board (my GPIO is reset to 0) all relays and LEDs go through initialization and my application is back to normal.

One of the most important requirements is for us to determine that we were reset by the watchdog so that we can record this anomaly.  According to the documentation this should be accomplished by inspecting the state of the WDFLAG.  However this flag does not get set as documented in both the Data Manual (SPRS439M) or the System Control and Interrupts (SPRUFB0D) documents.  So I need help to determine why is this flag not getting set to 1 on a watchdog reset.

Here are the initialization steps in my watchdog init function:

bool Watchdog_checkAndInitialize()
{
    bool boardWasResetByWatchdog = false;

    // Configuration for the Watchdog Control Register (WDCR)
    //    bit 15:8  Reserved (writing to these bits has no effect)
    //    bit    7  WDFLAG - 0 is ignored in this bit
    //    bit    6  WDDIS  - 0 enables the watchdog module
    //    bit  5:3  WDCHK  - 101b = 5 to avoid an immediate device reset
    //    bit  2:0  WDPS   - 111b = 7 to select 64 as the prescaler for the
    //                              wdclock signal producing a 916Hz clock
    //
    // Time for watchdog to expire is determined as follows:
    //   - 30MHz OSCCLK / 512 / 64 = 916Hz clock
    //   - 256 counts / 916 counts per second = 280msec
    //
    // Register Initialization Value:
    //  F E D C  B A 9 8  7 6 5 4  3 2 1 0  bit position
    //  0 0 0 0  0 0 0 0  0 0 1 0  1 1 1 1  binary setting per bit
    //        0        0        2        F  hex set value
    uint16_t watchdogConfigurationValue = 0x002F;


    // WDCR bit 7  WDFLAG - if this bit is 1 the watchdog caused the reset
    if ( (SysCtrlRegs.WDCR & 0x0080) != 0 )
    {
        boardWasResetByWatchdog = true;
        watchdogConfigurationValue |= 0x0080; // set WDFLAG clear bit in configuration value
    }

    // Allow for watchdog to be configured via the System Control and Status Register (SCSR)
    //    bit 15:3  Reserved - writing to these bits has no effect
    //    bit    2  WDINTS - read only, state of WDINT signal
    //    bit    1  WDENINT set to 0 to configure watchdog to do a reset
    //    bit    0  WDOVERRIDE set to 1 allows to change WDDIS in WDCR
    EALLOW; // Below register is "protected", allow access.
    SysCtrlRegs.SCSR = 0x0001;
    EDIS;   // Disable register access

    EALLOW; // Below register is "protected", allow access.
    SysCtrlRegs.WDCR = watchdogConfigurationValue;
    EDIS;   // Disable register access

    isWatchdogInitialized = true;

    //--------------------------------------------------------------------------------------------------
    // RR - DEBUG BLOCK START  -- TODO REMOVE BLOCK BEFORE COMMIT
    if ( boardWasResetByWatchdog ) GpioDataRegs.GPASET.bit.GPIO11 = 1;  // this one allows me to see in the scope that WDFLAG was set
    GpioDataRegs.GPASET.bit.GPIO5 = 1; // this one allows me to see in the scope that this code executed
    // RR - DEBUG BLOCK STOP
    //--------------------------------------------------------------------------------------------------

    return boardWasResetByWatchdog;
}

I have performed the following measurements:

  • From power on (CH1) to XRS (CH2) signal high there are about 240msec

  • During the watchdog reset (CH1 monitors my debug GPIO set high upon command to let watchdog expire) the XRS (CH2) signal remains high

Per TI documentation the XRS signal is supposed to go low for 512 OSCCLK.  But this does not happens.  

Questions:

  • Is the WDRST signal tied to the XRS signal inside the microcontroller or is this something we are supposed to do in our custom board?
  • Does my code above looks correct?
  • Is there a watchdog setup and WDFLAG check sample code available?
  • Why the WDFLAG not getting set to 1?

Thank you.

Rafael

  • Hi Rafael,

    Is the WDRST signal tied to the XRS signal inside the microcontroller or is this something we are supposed to do in our custom board?

    Yes, WDRST signal is tied to XRS signal inside MCU. This is Open-Drain circuit hence user need to have pull-up on this pin on board and drive '0' when need to apply the reset.

    Does my code above looks correct?

    Code looks ok to me.

    Is there a watchdog setup and WDFLAG check sample code available?

    There is an example code in controlSUITE (controlSUITE\device_support\f2833x\v140\DSP2833x_examples_ccsv5\watchdog). Please have a look into this.

    Why the WDFLAG not getting set to 1?

    WDFLAG should get set when reset is applied by WD. Now in this case XRSn itself is not toggling hence we need to first find what's causing that.

    Regards,

    Vivek Singh

     

  • Hi Vivek,
    The sample code in the controlSUITE package configures the watchdog to generate an interrupt.

    Questions:
    Is there example code that configures the WD to reset the device and the logic in the reset sequence that inspects the WDFLAG?
    How can I determine if there is any library/device initialization code clearing the WDFLAG before my application can inspect it?
    How can I trap writes to the WDCR via Code Composer?

    Thank you.
    Rafael
  • Hi Rafel,

    How can I determine if there is any library/device initialization code clearing the WDFLAG before my application can inspect it?
    How can I trap writes to the WDCR via Code Composer?



    In CCS you can use "Hardware Watchpoint" feature for this. Following is the step for the same.

    In CCS click on "View" -> "Breakpoints". In breakpoint menu click on drop down menu and then choose "Hardware Watchpoint" and enter the address for which you want to trap the writes and click "Ok".

    Regards,

    Vivek Singh

  • Rafael,


    The behavior of the WDFLAG bit is not well described in the documentation. We have a wiki page that describes its behavior:

    I will submit a documentation update to put this link into the F2833x system control reference guide.

  • Hi Adam,

    The wiki you pointed to has a better description of how the WDFLAG is supposed to work. However based on this augmented information and the measurements that we are taking the timing in our system seems correct, but the WDFLAG remains at 0 at all times.

    Here is a measurement of the XRS (CH1) and a GPIO (CH2) that we turn on when the Watchdog is enabled during the power up initialization.

    At time T the watchdog expires and creates a reset making both signals go low.  The XRS signal stays low for about 17usec which is what we expect for 512 cycles with a 30MHz OSCCLK.  The XRS signal goes back to high in at most 80usec.  Based on the wiki you pointed to the WDFLAG should go high if XRS is high before 1.1 millisecond ( (8192 * 4) + 512 cycles of 30MHz OSCCLK) after the watchdog reset occurs.

    The Wiki you pointed to is specific to the Picolo processor.  We are using the Delfino family.

    Questions:

    • What is the XRS sample delay after a WDRST for the Dolfino?
    • Is this delay fixed based on hardware or is it configurable by software?
    • Any suggestions on how to troubleshoot this issue?

    Thank you,

    Rafael

  • Rafael,

    The F2833x watchdog is the same one used on Piccolo.

    How long after reset are you waiting before you try to read the WDFLAG bit? With your OSCCLK, the bit will not be valid until ~1.1 milliseconds after reset.

  • Hi Vivek,

    Our application code was correct and so is our custom board.

    Using this Hardware Watchpoint we were able to trap and trace back to a board initialization library as the culprit of our issue.

    This function ti_catalog_c2800_init_Boot_disableWatchdog during boot disables the watchdog writing 0x00E8 clearing the WDFLAG.

    Via the Boot/Startup Options we unchecked the Disable the watchdog timer option and problem solved.  Now the WDFLAG stays on after a watchdog reset.

    Thank you.

    Rafael

  • Rafel,

    Glad  to know it is wokring now.

    Regards,

    Vivek Singh