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.

TMS320F280039C: No watchdog reset if no delay applied between config and activation

Part Number: TMS320F280039C
Other Parts Discussed in Thread: C2000WARE

Tool/software:

During the tests to simulate an infinite loop, I noticed that the watchdog reset didn't occur 100% of the time. With 10 tries, I have 3 cases where the reset occurred and 7 cases where the software doesn't do a reset.

The code sequence I use for configuration is:

  /*Configure predivider*/
  SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_512);

  /*Configure prescaler*/
  SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);

  /*Configure watchdog mode*/
  SysCtl_setWatchdogMode(SYSCTL_WD_MODE_RESET);

  /* Enable watchdog */
  SysCtl_enableWatchdog();

With the optimizations set to level 4.

The workarounds to get a reset on every try are as follows :

  • Define the optimizations to 0

OR

  • Add a delay of 1µs between SysCtl_setWatchdogMode and SysCtl_enableWatchdog

OR

  • Comment the line SysCtl_setWatchdogMode(SYSCTL_WD_MODE_RESET);

OR

  • Update the sequence of the code by :
    • SysCtl_setWatchdogMode(SYSCTL_WD_MODE_RESET);
    • SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_512);
    • SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
    • SysCtl_enableWatchdog();

In case I try with this sequence I have the same problem :

  • SysCtl_setWatchdogPredivider(SYSCTL_WD_PREDIV_512);
  • SysCtl_setWatchdogMode(SYSCTL_WD_MODE_RESET);
  • SysCtl_setWatchdogPrescaler(SYSCTL_WD_PRESCALE_64);
  • SysCtl_enableWatchdog();

When I look at the disassembly code, turning off optimizations results in more code (function calls)

With Optimizations :
  

Without Optimizations

When the watchdog reset doesn't occurs I can see that the register is configured the same way as when it works :

The WDCNT then increases to 0x00FF then returns to 0 but without triggering a reset.

Tests seem to show that when configuring Watchdog Mode it's necessary to apply a certain delay before activating the watchdog, otherwise sometimes the reset doesn't occur even if the register indicates that the watchdog reset is enabled.

Can you confirm the problem and what would be the recommended workaround?

Thanks