Error in Multi-Rate Timer (MRT) with multiple channel

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Error in Multi-Rate Timer (MRT) with multiple channel

跳至解决方案
1,987 次查看
hemanthvasista
Contributor IV

Hello ,

I am working on the LPC546xx based device. I tried using Multi-Rate Timer (MRT) with multiple channel.

When I configure either of one channel, they work fine individually.
But when I enable both channel, channel-0 is interrupted at different time and no interrupt is generated on channel-1.

Below is code snippet

    /* mrtConfig.enableMultiTask = false; */
    MRT_GetDefaultConfig(&mrtConfig);

    /* Init mrt module */
    MRT_Init(MRT0, &mrtConfig);

    /* Setup Channel 0 to be repeated */
    MRT_SetupChannelMode(MRT0, kMRT_Channel_0, kMRT_RepeatMode);
    MRT_SetupChannelMode(MRT0, kMRT_Channel_1, kMRT_RepeatMode);

    /* Enable timer interrupts for channel 0 */
    MRT_EnableInterrupts(MRT0, kMRT_Channel_0, kMRT_TimerInterruptEnable);
    MRT_EnableInterrupts(MRT0, kMRT_Channel_1, kMRT_TimerInterruptEnable);

    /* Enable at the NVIC */
    EnableIRQ(MRT0_IRQn);

    MRT_StartTimer(MRT0, kMRT_Channel_0, 22000);       //100us interrupt
    MRT_StartTimer(MRT0, kMRT_Channel_1, 220000); //1ms interrupt

The ISR is as below:

void MRT0_IRQHandler(void)
{
    if(MRT_GetStatusFlags(MRT0, kMRT_Channel_0))
    {
        MRT_ClearStatusFlags(MRT0, kMRT_Channel_0, kMRT_TimerInterruptFlag);
        APP_LED_TOGGLE;
    }
    else if (MRT_GetStatusFlags(MRT0, kMRT_Channel_1))
    {
        MRT_ClearStatusFlags(MRT0, kMRT_Channel_1, kMRT_TimerInterruptFlag);
        APP_LED_TOGGLE_1;
    }

/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
  exception return operation might vector to incorrect interrupt */
#if defined __CORTEX_M && (__CORTEX_M == 4U)
    __DSB();
#endif
}

regards,
Hemanth

标签 (2)
标记 (2)
0 项奖励
回复
1 解答
1,896 次查看
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Hemanth S

 

When channel 1 interrupts channel 0 also gets the interruption. I suggest you add a counter in the interruption on channel 0, when it reaches 1ms, the interruption of the channel 0 is disabled with "MRT_ClearStatusFlags" in order to enter the interruption of channel 1.

Another thing I can suggest is to do this comparison in the "if" sentence

If( 0x3 == MRT_GetStatusFlags(MRT0, kMRT_Channel_0) )

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.

Best regards,

Omar

在原帖中查看解决方案

2 回复数
1,897 次查看
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Hemanth S

 

When channel 1 interrupts channel 0 also gets the interruption. I suggest you add a counter in the interruption on channel 0, when it reaches 1ms, the interruption of the channel 0 is disabled with "MRT_ClearStatusFlags" in order to enter the interruption of channel 1.

Another thing I can suggest is to do this comparison in the "if" sentence

If( 0x3 == MRT_GetStatusFlags(MRT0, kMRT_Channel_0) )

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.

Best regards,

Omar

1,896 次查看
hemanthvasista
Contributor IV

Thanks for you inputs Omar.

Add of the below line solved the issue:

If( 0x3 == MRT_GetStatusFlags(MRT0, kMRT_Channel_0) )

regards,

Hemanth

0 项奖励
回复