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.

Watch dog

Part Number: TMS320F2800137
Other Parts Discussed in Thread: MOTORWARE, LAUNCHXL-F2800137

Hi expert:

   

when i set the watch dog mode(reset),wdclk=osc1/256;service dog and enable watchdog,I see ,after mcu reset 2 times ,the mcu is normal ,no reset occur again.why?

and after this operation , i donnot program the mcu by jtag,warning :failed unlcok device (zone1) after reset.warning :failed unlcok device (zone2) after reset..out load failed.

when the load the .out file ,the mcu is reset.

how to erase all  the flash?

  • I test in the c2000 motorware example(watchdog_ex1_service)

    step1.changed the watchdog mode to reset,the mcu always reset.

    step2.base on  step1,set the predivider(4) and presacle(64),the mcu always reset.

    step3.base on  step2,I changed the optimization level from off to 2 in the ccs setting,after mcu reset 7 times ,the mcu is normal ,no reset occur again.

    Take a look and try it out, it's easy to reproduce。

    Find the reasion and tell me?thanks

  • Have you checked if CPU is executing watchdog code when it's not getting reset ? Also which version of C200Ware you are using ? 

  • c2000ware5.00.

    after mcu reset 7 times ,the mcu is normal,i used the gpio test,the watchdog is enable and the WDCNT is running,but not reset the mcu.

    You can test used the c2000 motorware example(watchdog_ex1_service) and check the step3.

    Find the reasion and tell me?thanks

  • Ok, we'll check and get back to you. 

    Vivek Singh

  • Has the problem been reproduced?

  • We have yet reproduce this issue. Would it be possible for you to send the project at attachment ?

  • sorry,my computer encrypted, unable to send;

    You can test in the c2000 motorware example(watchdog_ex1_service)

    step1,used the following code in init fucntion; do not enable watchdog interrput;

    SysCtl_SetWatchdogMode(SYSCTL_WD_MODE_RESET);

    SysCtl_SetWatchdogPredivider(SYSCTL_WD_PREDIV_4);

    SysCtl_SetWatchdogPreScaler(SYSCTL_WD_PRESCALE_64);

    SysCtl_serviceWatchdog();

    SysCtl_enableWatchdog();

    step2.change the optimization level from off to 2 in the ccs setting;

  • Ok, no problem. We'll try the steps you have mentioned. 

    Vivek Singh

  • Hello Youjun,

    Do you see any difference when optimization is off and set to 2 ? I will try to test the ex1 by tomorrow to replicate the issue

    Thanks,
    Prarthan.

  • Hello Youjun,

    I tried the ex1 on f2800137x launchpad it works fine when the optimizations are off. But when I turn on optimization to 2 as you mentioned For loop inside main() doesn't get executed ever and keeps triggering wakeISR repeatedly. 
    Please try with optimization off and step through the code if problem persists.

    Thanks,
    Prarthan.

  • Thanks,
    Prarthan.

    Fisrt,My project need turn on optimization to 2.

    second: You said:"But when I turn on optimization to 2 as you mentioned For loop inside main() doesn't get executed ever and keeps triggering wakeISR repeatedly. "why?Can you find the reasion ?

  • Sure Youjun, I am reaching out to the compiler team to inquire about this.
    Please expect a response in one or two days.

    Thanks.

  • Hello Youjun,

    It seems to work fine, I misunderstood the loop unfolding that occurred due to optimization hence it removed the unused loopcount variable.

    Otherwise I changed the ex1 as following and I can confirm its getting reset and entering the code_start in disassembly view every time tried multiple iterations.

    void main(void)
    {
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();
    
        //
        // Re-map watchdog wake interrupt signal to call the ISR function in this
        // example
        //
        Interrupt_register(INT_WAKE, &wakeupISR);
    
        //
        // Clear the counters
        //
        wakeCount = 0;
        loopCount = 0;
    
        //
        // Set the watchdog to generate an interrupt signal or a reset signal
        //
        //SysCtl_setWatchdogMode(SYSCTL_WD_MODE_INTERRUPT);
         SysCtl_setWatchdogMode(SYSCTL_WD_MODE_RESET);
    
        //
        // Enable the watchdog wake interrupt signal
        //
        Interrupt_enable(INT_WAKE);
    
        //
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        //
        EINT;
        ERTM;
    
        SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_4);
    
        SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
        //
        // Reset the watchdog counter
        //
        SysCtl_serviceWatchdog();
    
        //
        // Enable the watchdog
        //
        SysCtl_enableWatchdog();
    
        //
        // Loop Forever
        //
        for(;;)
        {
            loopCount++;
    
            
        }
    }

  • Hi

    the mian code as follow,used reset mode,turn on optimization to 2 

    void main(void)
    {
    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();

    //
    // Re-map watchdog wake interrupt signal to call the ISR function in this
    // example
    //
    //Interrupt_register(INT_WAKE, &wakeupISR);

    //
    // Clear the counters
    //
    wakeCount = 0;
    loopCount = 0;

    //
    // Set the watchdog to generate an interrupt signal or a reset signal
    //
    //SysCtl_setWatchdogMode(SYSCTL_WD_MODE_INTERRUPT);
    SysCtl_setWatchdogMode(SYSCTL_WD_MODE_RESET);

    //
    // Enable the watchdog wake interrupt signal
    //
    //Interrupt_enable(INT_WAKE);

    //
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    //


    //
    // Reset the watchdog counter
    //
    SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_4);
    SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
    SysCtl_serviceWatchdog();
    //SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_4);
    //SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
    //
    // Enable the watchdog
    //
    SysCtl_enableWatchdog();
    EINT;
    ERTM;
    //
    // Loop Forever
    //
    for(;;)
    {
    loopCount++;

    //
    // Uncomment SysCtl_serviceWatchdog to just loop here.
    // Comment SysCtl_serviceWatchdog to have watchdog timeout and trigger
    // an interrupt signal to execute the wakeupISR
    //
    // SysCtl_serviceWatchdog();
    }
    }

    the test picture as follow,the yellow signal is the test GPIO,the pink singal is reset pin

    Yon can see ,after 3 reset,the mcu is work fine,do not reset again.

    i used the gpio test,the watch dog configure is right,the watchdog is enable and the WDCNT is running,but not reset the mcu.

    You can test reset mode.

    thanks.

  • Hello Youjun,

    I have the same code as you mentioned above. I cant replicate the issue. 
    Yellow is the XRSn pin from scope tested on LAUNCHXL-F2800137, I can get continuous resets which is the expected behavior since we are not servicing watchdog in loop

    Thanks!

  • Thanks;

    Did you turn on optimization to 2 ?

    I will test in the demo board,but why is not reset in my board?the boot mode is GPIO mode.

  • Thanks;

    tested on LAUNCHXL-F2800137. the same code as I mentioned above,I can get continuous resets.

    when i changed the code as follow;"EINT;ERTM"before configure.,other code is same.

    //
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    //

    EINT;
    ERTM;
    //
    // Reset the watchdog counter
    //
    SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_4);
    SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
    SysCtl_serviceWatchdog();
    //SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_4);
    //SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
    //
    // Enable the watchdog
    //
    SysCtl_enableWatchdog();

    after some reset,the mcu is work fine,do not reset again.

    You can Test.

  • I will try to replicate the code by tomorrow and let you know.

    Thanks!

  • Thanks.

    You can test more times.

    the reset counter is different.

  • Has the problem been reproduced?

  • Hello Youjun,

    Please expect delay in my response due to MLK holiday, I will update by end of week.

    Thanks!

  • Hi expert:

    Has the problem been reproduced?

  • Hello Youjun,

    Yes I was able to replicate the issue.This happens only when the prescalers and divider to set to different value then default.
    If you don't change the default values it works as intended giving multiple resets.

    Let me debug, troubleshoot it get back to you.

    Thanks,
    Prarthan.

  • Hello Youjun,

    Can you try with the following changes in the code :

    SysCtl_serviceWatchdog();
    SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_4);
    SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64); <----This works and generates resets continuously

    instead of

    SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_4);
    SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
    SysCtl_serviceWatchdog();    <------ This sequence doesn't work it stops after 1 or 2 resets

    I have verified in this on launchpad it works as expected generating continuous resets.
    Still trying to debug why the sequencing of servicewatchdog function makes difference with respect to divider and prescale settings.

    Thanks!
    Prarthan

  • Hi Prarthan,

    Okay, please investigate the cause and let me know. Thank you

  • Hello Youjun,

    Because of the below requirements it is recommended to put a delay of specified cycles so that the register writes are executed properly.

    Since you are writing to predivider and prescaler back to back; its recommended to put a delay at end of write in both functions like shown below for example you can add any delay function as you would like instead of NOP.

    I have tried below and its working with the sequence also.

    Thanks,
    Prarthan.

  • Hi Prarthan:

    Ok, thank you for your hard work. This issue is indeed difficult to detect, and it should be specifically noted in some place.

  • According to the document description,second write can be lost.

    When the watchdog is abnormal,i used the gpio test,in the main cycle,i read the watch dog register,the watch dog configure is right,the watchdog is enable and the WDCNT is running,but not reset the mcu.

    You can confirm.

  • Hello Youjun,

    That delay is needed for proper configurations to be set internally.
    You can see the difference by adding NOP's delay in the function v/s without.
    Optionally you can try by writing to one bit just prescalar or divider in WDCR instead of both and see difference both should validate your doubt.

    Thanks,
    Prarthan.