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 Q &A

Other Parts Discussed in Thread: TPS65381-Q1

Hi,

Iam Himaja.I am currently working on TPS65381 PMIC Watchdog Q&A communicating with RH850 MCU.

Can you please help me in understanding how does Q&A process goes on.

To my understanding MCU asks for token and PMIC gives the token.

and then MCU ask for Answer and PMIC will give the answer in 32bits 3 answers in open window duration and one answer in close window duration.

Am I understanding it correctly.

Can you help me how to implement it?

Thanks,

Himaja

  • Hi Himaja-san,

    Please make sure you are using Revision F of the TPS65381-Q1 datasheet, we have revised the watchdog section to make it more understandable, one f the changes being focusing on the terms Question and Answer, instead of Token and variations on token.  

    All of my references are using Revision F of the datasheet.  

    The basic principle is to set up the watchdog sequence (window 1 + window 2) and synchronize to the Q&A watchdog timing from the MCU to the TPS65381, outlined in Figure 6-11 and in section 5.4.1.14 MCU to Watchdog Synchronization.  Once WD_WIN1_CFG or WD_WIN2_CFG is written the TPS65381 will start a new watchdog sequence and the MCU should start it's watchdog timing so the TPS and MCU are synchronized.

    The MCU should read the Question (Token) in TOKEN[3:0] in register WDT_TOKEN_VALUE.

    The MCU should calculate the Answer (Response).  The answer (response) is a 32-bit word that is split into four answer bytes (Answer-x) or responses: Answer-3, Answer-2, Answer-1 , and Answer-0.  The TPS65381 watchdog receives an answer byte (Answer-x) when the MCU writes to the watchdog answer register (WDT_ANSW[7:0] bits in the WDT_ANSWER register).   The MCU uses the Figure 5-10 Watchdog Answer (Response) Calculation to calculate the Answer-x bytes.  

    The MCU must provide the Answer-x bytes to the TPS in the correct order.  Answer-3, -2, and -1 may be in either Window 1 or Window 2.  However Answer-0, must be in Window 2 for it to be counted as a "good event".  

    Once the first "good event" occurs, the TPS will decrement the watchdog fail counter and start a new watchdog sequence including generating a new question.  And the process is repeated.

    Attached is a draft spreadsheet that will help you calculate the timing needed from the MCU to make sure the TPS65381 will receive the answer as a "good event".

    DRAFT TPS65381-Q1 wd-clock-tolerance-calculation - For E2E.xlsx

    Hopefully this helps you understand what is needed for the watchdog.  

    Best Regards,

    Scott

  • Hi Himaja-san,

    I'm also going to move this into the Automotive forum, which is normally the forum from which we support this device.

    Best Regards,
    Scott
  • Thank you for the response.

    I have set watchdog to desired mode.
    I have written values to Window config registers.
    I am unable to understand onething Within Window 1 duration we have to calculate and send three answers to TPS ,correct?How can we do this like we have use MCU timr as reference.

    If I read the token value we will get only the default value correct?
    CAN MCU write the Token_seed value and Token value are one and the same?If so,Can we write the Token seed value and then start calculating the answers?

    Can you help me if you have any examples of how to send answers.
    Iam able to calculate the answer but sending itwindow duration is what iam unable to understand.

    Thanks and Regards,
    Himaja
  • Hello Scott,

    I would like to understand how to manage TPS65381 from MCU.

    Like I need to start the timer of MCU and then Initialize the TPS  in Q&A mode .

    Then Read the token and then calculate and Send the answers to the TPS

    While sending we have take the time of MCU timer and manage to send the first three answers in Open window duration limit and then start sending the fourth answer in close window duration  . after that reask for the token and the procedure goes on.

    Is my understanding correct?

    Can you please help me if you have any application code implemented for MCU.

  • Hi Himaja,

    Your basic understanding is correct, but see below for a little more detail.   Please make sure you have the latest datasheet, Rev F from  

    The synchronization flow is Figure 6-11 on page 109.  Make sure you read through sections 5.4.1.11 (page 47) to 5.4.1.16.4 (page 63).  This has all the critical information on how the watchdog works including specific sections on the WD sequence, WD synchronization and how the Q&A mode works.  

    You need first to configure the WD for Q&A Mode, then synchronize the MCU to the WD timer by initializing WINDOW 1 and WINDOW2 (the WD sequence) for operation, I would do this before starting the timer in the MCU.  Immediately on writing WD_WIN2_CFG a new watchdog sequence starts so start your timer at this point so both the MCU and TPS65381 have started their timers together and are synchronized.  

    Then you need to read the question (TOKEN) and calculate the Answer-x bytes.  The first three answer-x bytes are allowed to be in either WINDOW 1 (OPEN) or WINDOW2 (CLOSE).  You can choose your strategy on when to write them.  Answer-0 byte, the 4th answer byte has to be in WINDOW 2.  We recommend timing it so that it is in the middle of the known time for WINDOW 2.  The spreadsheet I already posted will help you with this by calculating the known times for both WINDOW 1 and WINDOW 2 for the HEX value you write into the WD_WIN1_CFG and WD_WIN2_CFG registers.    

    The actual SPI code to write to the TPS65381 and set the timers in the MCU should be provided by the MCU vendor.  Normally they have base libraries for these simple functions.  The TMS570 / Hercules from TI has more extensive libraries for the TPS65381.

    I have attached an XLS with some Pseudo code flow for the SPI commands and timing to give you a few examples of how to run the WD.  I have not included any trap routines you want to write incase when reading the status registers for the watchdog an error flag has been set.  That is really application dependent if you want to try to correct for it, or let the MCU continue "bad events" and get RESET when the WD_FAIL_CNT increments too far.

    2016-09-23 Watchdog Pseudo Code for TPS65381-Q1 -- Draft for E2E.xlsx

    Best Regards, Scott

  • Thanks Scott,

    I have followed the pseudo code u sent.

    I would like to know if there are any necessary hardware connections to be taken care of inorder for watchdog to work in Q&A mode?

    Will the TPS automatically resets MCU at some point of time like if Fail_cnt reaches 7.

    Iam not able to get any update in ANswer variable .please find the calculation for answer I have done below.

    U8 PmicCalculateWatchdogAnswer(void)
    {
      U16 token0,token1,token2,token3,anscnt0,anscnt1;
     
     
       token0 = PmicReadWatchdogToken() & 0xF;
      token1 = (token0 >> 1) & 1;
       token2 = (token0 >> 2) & 1;
       token3 = (token0 >> 3);
       anscnt0 = (PmicReadWatchdogStatus() >> 6) & 3;
       anscnt1 = (anscnt0 >> 1) & 1;
      token0 &= 1;
      anscnt0 &= 1;
      answer = (token0 ^ (anscnt1 ^ token3)) |
      ((token0 ^ anscnt1 ^ (token1 ^ token2)) << 1) |
      ((token0 ^ anscnt1 ^ (token3 ^ token1)) << 2) |
      ((token2 ^ anscnt1 ^ (token0 ^ token3)) << 3) |
      ((token1 ^ anscnt0) << 4) |
      ((token3 ^ anscnt0) << 5) |
      ((token0 ^ anscnt0) << 6) |
      ((token2 ^ anscnt0) << 7);
     
      return answer;

    please let me know if iam going in right way.

    let me know your sugesstions to test WD.

    Thanks and Regards,

    Himaja

  • Hi Scott,

    TPS is entering into safe state even though I have set DIAG_EXIT_MASK bit in debug mode.

     when I read RD_SAFETY_STAT_5 I have a return value of 0x04 instead of 0x07.

    how can make the Watchdog saty in DIAGNOSTIC mode.

    Please answer as soon as possible.

    Thanks and Regards,

    Himaja

  • Hi Himaja,

    I will have to try to study your c-code examples tomorrow. If you cause any global SAFE state condition it will over ride the DIAG_EXIT_MASK. Also if you do not set DIAG_EXIT_MASK bit within 486ms of exiting RESET state (NRES going high) you will end up in SAFE state due to DIAGNOSTIC time out. In the datasheet see the state diagram, section 5.4.1.20 for SAFE state transitions and section 5.4.1.23 DIAGNOSTIC state for more details on DIAGNOSTIC State Time-Out.

    My guess is you are not writing the DIAG_EXIT_MASK in time and thus ending up in SAFE state.

    Scott
  • Thank you.Now TPS is in DIAG state.

    Can you let me know the process of answer calculation which ihave sent in previous mail is correct.

    Please let me know how to calculate the answer and token.

    Thanks and Regards,

    Himaja

  • I think the answer calculation is correct ,but iam unable to understand why the answer count is not decrementing automatically.
    If I manually decrement and calculate the answer I am able to get correct answer for given token value
    and the token value is not getting updated after each answer(4 answers).
    and the failcount is at 7 but not 5.

    void PmicSendWatchdogAnswer(void)
    {
    U16 the_word;
    U8 data,i;

    data=PmicCalculateWatchdogAnswer();
    PmicWriteWatchdogAnswer(data);
    AnswerCount--;

    the_word=0xC500;/*RD_SAFETY_STAT_2 Read Failcount value */
    SpiTxWord(SPI_PMIC, the_word, &Spi_Return);
    if((U8)Spi_Return<0x05)/* the return value here is always 0x07*/
    {
    count++;
    }

    if((U8)PmicReadWatchdogStatus()==0xC0)
    {
    count++;
    }


    if ((U8)PmicCheckForAnswerCount()==0x00)
    {
    the_word=0x35AC; /*WR_SAFETY_FUNC_CFG Configure WD_RST_EN for reset from watchdog failure*/
    SpiTxWord(SPI_PMIC, the_word, &Spi_Return);
    if((U8)Spi_Return==0xA5)
    {
    count++;
    }

    the_word=0x3A00;/*RD_SAFETY_FUNC_CFG to confirm the written value*/
    SpiTxWord(SPI_PMIC, the_word, &Spi_Return);
    if((U8)Spi_Return==0xAC)
    {
    count++;
    }

    the_word=0x9336;/*WR_SAFETY_CHECK_CTRLSet ENABLE_DRV and remain in Daignostic state*/
    SpiTxWord(SPI_PMIC, the_word, &Spi_Return);
    if((U8)Spi_Return==0x16)
    {
    count++;
    }
    the_word=0x4400;/*RD_SAFETY_CHECK_CTRL to confirm the values written*/
    SpiTxWord(SPI_PMIC, the_word, &Spi_Return);
    if((U8)Spi_Return==0x36)
    {
    count++;
    }
    }
    }