SWT interrupt not called

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

SWT interrupt not called

ソリューションへジャンプ
2,546件の閲覧回数
hbouch
Contributor III

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

ラベル(1)
0 件の賞賛
返信
1 解決策
2,088件の閲覧回数
hbouch
Contributor III

Peter,

I just got why you were talking about IVOR4. In software vector mode all interrupts are routed to IVOR4...

I fixed my problem. I was expecting an IVOR12 interrupt which was never trigger... (I still don't understand why because it's the IVOR dedicated to SWT but anyways). The IVOR4 interrupt for SWT jumps to interrupt vector 8 (has in the image above). With the right interrupt vector configured, it works much better !

Thanks Peter for leading me on the IVOR4 ! It really helped.

Cheers,
Hugo

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
2,089件の閲覧回数
hbouch
Contributor III

Peter,

I just got why you were talking about IVOR4. In software vector mode all interrupts are routed to IVOR4...

I fixed my problem. I was expecting an IVOR12 interrupt which was never trigger... (I still don't understand why because it's the IVOR dedicated to SWT but anyways). The IVOR4 interrupt for SWT jumps to interrupt vector 8 (has in the image above). With the right interrupt vector configured, it works much better !

Thanks Peter for leading me on the IVOR4 ! It really helped.

Cheers,
Hugo

0 件の賞賛
返信
2,088件の閲覧回数
petervlna
NXP TechSupport
NXP TechSupport

Hi,

As SWT is periphery external to the core it must go trough IVOR4 (external interrupt).

Peter

0 件の賞賛
返信
2,088件の閲覧回数
petervlna
NXP TechSupport
NXP TechSupport

Hi,

If the IF is set, it means that SWT sent interrupt request to INTC module.

SWT is configured properly.

I will check INTC configuration as well as IVOR4 handler.

As reference you can use this example:

https://community.nxp.com/docs/DOC-329563 

Make sure you have priority set for SWT interrupt in INTC.

Place breakpoint on IVOR4 address to see if the code jumps there immediately after IF is set.

Peter

0 件の賞賛
返信
2,088件の閲覧回数
hbouch
Contributor III

Hello Peter,

Thanks for your answer. IVOR4 is for external interrupt and not SWT interrupt. Am I right?

If I understand the E200z6 core reference manual, watchdog timeout triggers IVOR12.

Also, I belive the IF bit could be set without interruption the CPU as for other modules in the microcontroller if corresponding interrupt is not enabled. Shouldn't the bit TSR[WIS] = 0 be set if IF bit is set?

There is also interrupt vector 8 that is related to SWT:

pastedImage_1.png

I tried to set my isr on both interrupt but without success. And to answer your question, yes I configure the priority of the interrupt to the max value.

Any other idea?

Thanks,

Hugo

0 件の賞賛
返信