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.

TMS320F280025: Hardfault Handler - How to use a callback?

Part Number: TMS320F280025


Hi,

I have seen, that the hardfault interrupts are inside the interrupt.h (at least in the universal motor control project). So when somehow a hardfault occurs while runtime, it will just jump there and does nothing. So since interrupt.h is a library and only reference, I would not like to modify this file and my question is, how should one register a own callback here to shut down the motor before it hangs inside this ISR? I know from other manufacturer, that they only have weak ISR routines and I can then define my own to easy overcome this problem.

  • Hi, that does not really answere my question. My problem is pretty specific with the universal motor control SDK example.

    These use as drivers the interrupt.h from the driverlib. Any hardfault will result in a ISR jump into the specific routine inside interrupt.h

    and since this library is only reference in the example, I'm not directly able to access these callbacks without heavy modification of the

    whole project.

    Here is for example the Interrupt_defaultHandler in interrupt.h:

    //*****************************************************************************
    //
    //! \internal
    //! The default interrupt handler.
    //!
    //! This is the default interrupt handler.  The Interrupt_initVectorTable()
    //! function sets all vectors to this function.  Also, when an interrupt is
    //! unregistered using the Interrupt_unregister() function, this handler takes
    //! its place.  This should never be called during normal operation.
    //!
    //! The ESTOP0 statement is for debug purposes only. Remove and replace with an
    //! appropriate error handling routine for your program.
    //!
    //! \return None.
    //
    //*****************************************************************************
    static void Interrupt_defaultHandler(void)
    {
        uint16_t pieVect;
        uint16_t vectID;
    
        //
        // Calculate the vector ID. If the vector is in the lower PIE, it's the
        // offset of the vector that was fetched (bits 7:1 of PIECTRL.PIEVECT)
        // divided by two.
        //
        pieVect = HWREGH(PIECTRL_BASE + PIE_O_CTRL);
        vectID = (pieVect & 0xFEU) >> 1U;
    
        //
        // If the vector is in the upper PIE, the vector ID is 128 or higher.
        //
        if(pieVect >= 0x0E00U)
        {
            vectID += 128U;
        }
    
        //
        // Something has gone wrong. An interrupt without a proper registered
        // handler function has occurred. To help you debug the issue, local
        // variable vectID contains the vector ID of the interrupt that occurred.
        //
        ESTOP0;
        for(;;)
        {
            ;
        }
    }

    It states, that the ESTOP is for debug only and that it should be replaced with a error handling routine.

    So, can I somehow easy register an error callback for any hardfault from the application or do I really need

    to modify the interrupt.h?

  • Hello Sebastian,

    Can you use the pieVect and vectID to determine which interrupt is being triggered that it says is not configured to an ISR? If possible, can you also list the interrupts you are using which you are expecting?

    Best regards,

    Omer Amir

  • Hi Amir,

    Thanks I could solve it, just register an interrupts an it takes the new handler.