AnsweredAssumed Answered

SWT interrupt not called

Question asked by Hugo Bouchard on Nov 9, 2016
Latest reply on Nov 10, 2016 by Peter Vlna

Hello,

 

I want to setup SWT watchdog from the microcontroller (MPC5668G). Here is the init function to setup the watchdog. As you can see, I've setup the watchdog to interrupt first and then reset on second consecutive timeout. However, even if a watchdog timer timeout occurs, the ISR is never called.

 

/*==============================================================================
 * Function name: SWT_Init
 * Description:   This function initializes the Software Watchdog Timer.
 * Inputs:
 *     eMode -> Watchdog refresh mode (normal, window)
 *     eAction -> Action to be taken when watchdog timeout occurs
 *     u32Timeout -> Watchdog timeout in ms
 *     u32WindowStartValue -> Value after which watchdog should be refreshed if
 *                            window mode is used (ignored in normal mode) in ms
 *     pfIsr -> Function that will be call upon watchdog timeout
 * Outputs:
 *     None
==============================================================================*/
void SWT_Init(SWT_eWatchdogMode eMode, SWT_eWatchdogAction eAction, uint32_t u32Timeout, uint32_t u32WindowStartValue, INT_ISR_FPTR pfIsr)

{
    uint32_t u32NbClkTicks;
    vuint32_t u32TmpTCR;
    vuint32_t u32TmpTSR;
    vuint32_t u32TmpMSR;
    vuint32_t u32TmpCR;

 

    /* Install interrupt function to be called */
    _int_install_isr(PSP_EXCPT_WATCHDOG_TIMER, pfIsr, NULL);
    _bsp_int_init(PSP_EXCPT_WATCHDOG_TIMER, 0, 0, TRUE);

 

    /* Clear any pending interrupt */
    SWT.IR.B.TIF = (vuint32_t)1;
    _PSP_SPR_GET(u32TmpTSR, E200CORE_TSR);
    u32TmpTSR |= E200CORE_TSR_WIS;
    _PSP_SPR_SET(E200CORE_TSR, u32TmpTSR);

 

    /* Enable watchdog interrupt */
    _PSP_SPR_GET(u32TmpTCR, E200CORE_TCR);
    u32TmpTCR |= E200CORE_TCR_WIE;
    _PSP_SPR_SET(E200CORE_TCR, u32TmpTCR);

 

    /* Enable critical interrupt */
    _PSP_MSR_GET(u32TmpMSR);
    u32TmpMSR |= E200CORE_MSR_CE;
    _PSP_MSR_SET(u32TmpMSR);

 

    /* Set watchdog mode */
    if(SWT_KE_MODE_WINDOW == eMode)
    {
        u32TmpCR |= SWT_KU32_CR_WND;

 

        u32NbClkTicks = (SWT_KU32_WATCHDOG_CLOCK_FREQ / (uint32_t)1000) * u32WindowStartValue;
        SWT.WN.R = u32NbClkTicks;
    }
    else
    {
        u32TmpCR &= ~SWT_KU32_CR_WND;
    }

 

    /* Set action to be taken when watchdog timeout occurs */
    if(SWT_KE_ACTION_INTERRUPT_THEN_RESET == eAction)
    {
        u32TmpCR |= SWT_KU32_CR_ITR;
    }
    else
    {
        u32TmpCR &= ~SWT_KU32_CR_ITR;
    }

 

    /* Watchdog counter stop in debug mode, enable access by z6 core, enable watchdog and hardware lock bit */
    u32TmpCR |= (   /*SWT_KU32_CR_FRZ
                  |*/ SWT_KU32_CR_MAP0
                  | SWT_KU32_CR_HLK
                  | SWT_KU32_CR_WEN);

 

    /* Set timeout value */
    u32NbClkTicks = (SWT_KU32_WATCHDOG_CLOCK_FREQ / (uint32_t)1000) * u32Timeout;
    SWT.TO.R = u32NbClkTicks;

 

    /* Update control register */
    SWT.CR.R = u32TmpCR;
}

 

For test purpose, I set a timeout value of 10 seconds to let me time with the debugger to break in the ISR. The FRZ bit in CR register of SWT is of course not set. Once the function SWT_Init has been called, the status of watchdog related registers is as follow:

 

MSR[CE] = 1

TCR[WIE] = 1

TSR[WIS] = 0

TSR[WRS] = 0

TSR[ENW] = 0

SWT_CR[MAP] = 0x80

SWT_CR[ITR] = 1

SWT_CR[HLK] = 1

SWT_CR[WEN] = 1

SWT_IR[IF] = 0

 

When the watchdog timeout, I can see that SWT_IR[IF] = 1 but TSR[WIS] = 0, TSR[WRS] = 0 and TSR[ENW] = 0.

 

I'm sure of the setup of my interrupt function (by the way I use MQX 4.1.1) and anyways, I've put a breakpoint in every OS functions that could be called upon an interrupt but no SWT interrupt... However, after 20 seconds (because I've configured SWT to interrupt then reset) the CPU is reseted.

 

Does anyone has an idea of what the problem could be? Did I forgot to set a register or something?

 

Thanks

Hugo

Outcomes