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.

  • Resolved

[FAQ] TPS65381A-Q1: Is there example code to calculate the answer-bytes for the Q&A watchdog?

Part Number: TPS65381A-Q1

Is there example code to calculate the answer-bytes for the Q&A watchdog in the device or should a look up table be used?

Best Regards,

Scott Monroe

--------------------------------------------------

For more information on Multi-Channel Power Management ICs: 

Find the right power solution for your processor or FPGA. Visit www.ti.com/SoCPower today!

  • To improve fault coverage of a microcontroller unit (MCU), an independent watchdog may be used to monitor the MCU. One type of watchdog is a question and answer (Q&A) watchdog, and is used in some devices like TPS65381A-Q1.

     

    The Q&A watchdog issues a question each watchdog sequence, and expects 4 answer bytes in the proper order and with the proper value. These questions are to test the MCU’s logic operation and provide higher diagnostic coverage of the MCU than a window watchdog. The MCU should calculate the answer bytes based on the question and answer count instead of using a look up table to maximize the diagnostic coverage. The following code provides an example of how to calculate the proper answer-bytes for the TPS65381A-Q1.

     

    // question is the current value in WD_QUESTION register (WD_TOKEN_VALUE register in TPS65381-Q1)

    // answerCount is the current value in WD_ANSW_CNT register

    uint8_t calculateAnswer(uint8_t question, uint8_t answerCount) {

     

       // answer0 is bit 0 of the answer byte, answer1 is bit 1 of the answer byte, etc.

        uint8_t answer0 = (question & 1) ^ ((answerCount & 2) >> 1) ^ ((question & 8) >> 3);

        uint8_t answer1 = (question & 1) ^ ((question & 4) >> 2) ^ ((question & 2) >> 1) ^ ((answerCount & 2) >> 1);

        uint8_t answer2 = (question & 1) ^ ((question & 8) >> 3) ^ ((question & 2) >> 1) ^ ((answerCount & 2) >> 1);

        uint8_t answer3 = ((question & 4) >> 2) ^ (question & 1) ^ ((question & 8) >> 3) ^ ((answerCount & 2) >> 1);

        uint8_t answer4 = ((question & 2) >> 1) ^ (answerCount & 1);

        uint8_t answer5 = ((question & 8) >> 3) ^ (answerCount & 1);

        uint8_t answer6 = (question & 1) ^ (answerCount & 1);

        uint8_t answer7 = ((question & 4) >> 2) ^ (answerCount & 1);

     

        return answer0 | (answer1 << 1) | (answer2 << 2) | (answer3 << 3) | (answer4 << 4) | (answer5 << 5) | (answer6 << 6) | (answer7 << 7);

    }

     

    Best Regards,

    Scott Monroe

    --------------------------------------------------

    For more information on Multi-Channel Power Management ICs: 

    Find the right power solution for your processor or FPGA. Visit www.ti.com/SoCPower today!

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.