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
已解决! 转到解答。
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
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