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.

TPS65381 Watchdog Startup Issue with RM48

My code is based on the TPS65381/RM46_FreeRTOS project. I am able to consistently transition to the DIAGNOSTIC state at power-up by setting the bit in the SAFETY_CHECK_CTRL register, and my Q+A WD code works and I am able to to get into the ACTIVE state and hold ENDRV high while sending a steady stream of WD answers. The problem is that it sometimes takes on the order of milliseconds to go ACTIVE and see the WdFailCount go to zero, and other times it may take 30 seconds, or 30 minutes, or forever. I stay in a DIAGNOSTIC state sending WD answers, waiting for the WdFailCount to drop to zero. Additionally, when I attach or remove the JTAG connector while the code is running and still in DIAGNOSTIC, the act of connection/removing the JTAG connector will cause the watchdog to start working and the 65381 goes ACTIVE and stays there. I am guessing this is due to ESD causing the MCU to reset? Can someone shed light on what is going on at startup, and explain what condition causes the watchdog to sometimes be satisfied immediately and sometimes after seconds/minutes/hours?
Thanks,
Bobby Goldberg

  • We have received your post and we will be back to you soon.

    Regards.

  • It is difficult to speculate the answer.

    1. Can you publish the open/close window period of the TPS65381 and the code where you serve the watchdog in the MCU

    2. SPI timings. What is the SPI frequency, and wdelay settings.

    Other than that, I will consider it as a hardware fault.

    Regards,

    Haixiao

  • Haixiao,
    Thanks for responding.
    I have run this on multiple devices (multiple RM48's) and the behavior is the same on all, so I don't think this is a hardware fault.

    Here is the SPI2 timing info:
    SPI Clk: 500KHz
    Chip Select Active to Transmit Start: 90.909ns
    Transmit End to Chip Select Inactive: 90.909ns
    Chip Select to ENA Timeout: 0.008ms
    Transmit Finish to ENA Inactive Timeout: 0.009ms

    Here is the setup I used for the open and close window configuration, which is copied from the FreeRTOS example

    unsigned short OPEN_WINDOW_CONFIG = 40, CLOSE_WINDOW_CONFIG = 15;
    ecmpWdgWindowConfig(OPEN_WINDOW_CONFIG, CLOSE_WINDOW_CONFIG);

    Here is the code that serves the Watchdog:
    (we are using SafeRTOS, which is based on FreeRTOS, e.g. xTaskDelay <=> vTaskDelay)

    ecmpInit();
    unsigned short OPEN_WINDOW_CONFIG = 40, CLOSE_WINDOW_CONFIG = 15;
    ecmpWdgWindowConfig(OPEN_WINDOW_CONFIG, CLOSE_WINDOW_CONFIG);

    ( *( volatile unsigned int * )0xFFF7BC00U ) = 1;
    ( *( volatile unsigned int * )0xFFF7BC54U ) = 1<<7;

    unsigned long TPSTaskCheck[4] = {0L};
    volatile unsigned long *pTPSTaskCheck;
    pTPSTaskCheck = &TPSTaskCheck[0];

    TPSTaskCheck[2] = OPEN_WINDOW_CONFIG/2;
    TPSTaskCheck[3] = OPEN_WINDOW_CONFIG/2+CLOSE_WINDOW_CONFIG/3;

    for (;;)
    {
      (*pTPSTaskCheck)++;
      short WdgFailCount = ecmpGetWdgFailCount();
      if (WdgFailCount == 0)
        {
        switch (*(pTPSTaskCheck+1))
          {
          case 0:
            if (ecmpEnableWdg())
            (*(pTPSTaskCheck+1))++;
            ecmpLockRegisters();
            break;
          case 1:
            if (ecmpLeaveDiagnosticState())
            (*(pTPSTaskCheck+1))++;
            break;
          default:
            break;
        }
      }
      ecmpSendWdgAnswer();
      ecmpSendWdgAnswer();
      ecmpSendWdgAnswer();
      xTaskDelay(*(pTPSTaskCheck+3));
      ecmpSendWdgAnswer();
      xTaskDelay(*(pTPSTaskCheck+2));
      if((*pTPSTaskCheck) & 0x1) ( *(volatile unsigned int *)0xFFF7BC60 ) = 1<<7;
      else (*( volatile unsigned int *)0xFFF7BC64 ) = 1<<7;
    }

     

    Thanks,

    Bobby

  • Can you check WDELAY field in SPIFMT register? Please set it to 0x7F (a arbitary big number).

    Please increase the SPI clock frequency to 1~5MHz.

    Is there any other task in the system that block the CPU from serving the watchdog?

    If possible, can you catch the wave form of SPI signal before/after you ask it to transfer from diagnostic to active mode.

    Regards,

    Haixiao

  • Thanks, Haixiao.  I increased the SPI clock to 1 MHz and changed the WDELAY to 127 (0x7F) and everything seems to work now.  I will do more testing to see where the frequency threshold is, below which we see the problem.  Is 127/0x7F a reasonable value for WDELAY?

    Bobby

  • OK, let me tell you the background and you judge it based on your system configuration.

    1. Between adjacent SPI transfer, the delay time has to be 3 sys clocks - 750ns total. This is required by the TPS65381. Dual to process variation, let's put 800ns, a safe number.

    2. Suppose the Hercules MCU runs with HCLK=160MHz, VCLK = 80MHz, the wdelay minimum value is:

    800ns * 80Meg -2 =62.

    Regards,

    Haixiao

     

  • So now that I can go active and feed the watchdog reliably, the next problem is that when I attempt to attach a JTAG device for debugging or flashing, the JTAG debugger does a soft reset on the MCU.  Within 20 or 30 msec,  the 65381 resets the Hercules and repeatedly tries to reset it, causing multiple JTAG errors.  At hard reset, we have 600 msec to get into DIAGNOSTIC state and get the watchdog working, but at soft reset, it seems we have very little time before the 65381 issues a RESET and we get into an infinite reset loop.  Is there a way of configuring the 65381 to allow enough time for the Hercules to reset itself?

  • Haixiao,

    Can you tell me how to configure the TPS65381 to prevent reset when the watchdog fails or at soft power-up?  I have NO_SAFE_TO bit set and SAFE_LOCK_THR = 0.  I can no longer debug because my MCU resets every time I try to debug or flash with JTAG.

    Thanks,

    Bobby

  • IN the example I provided, when switching from diag to active state, I set the SAFETY_FUNC_CFG register to 0x2F. If you don't want to trigger watchdog reset during debug, set it to 0x27. For detail information, please look at the datasheet of TPS65381.

    Regards,

    Haixiao

  • Setting WD_RST_EN to 0 did the trick - thanks for all of your help.

    Bobby