<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error in Multi-Rate Timer (MRT) with multiple channel in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Error-in-Multi-Rate-Timer-MRT-with-multiple-channel/m-p/1081290#M41536</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working on the LPC546xx based device. I tried using Multi-Rate Timer (MRT) with multiple channel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I configure either of one channel, they work fine individually. &lt;BR /&gt;But when I enable both channel, channel-0 is interrupted at different time and no interrupt is generated on channel-1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is code snippet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* mrtConfig.enableMultiTask = false; */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_GetDefaultConfig(&amp;amp;mrtConfig);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Init mrt module */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_Init(MRT0, &amp;amp;mrtConfig);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Setup Channel 0 to be repeated */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_SetupChannelMode(MRT0, kMRT_Channel_0, kMRT_RepeatMode);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_SetupChannelMode(MRT0, kMRT_Channel_1, kMRT_RepeatMode);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Enable timer interrupts for channel 0 */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_EnableInterrupts(MRT0, kMRT_Channel_0, kMRT_TimerInterruptEnable);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_EnableInterrupts(MRT0, kMRT_Channel_1, kMRT_TimerInterruptEnable);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Enable at the NVIC */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EnableIRQ(MRT0_IRQn);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_StartTimer(MRT0, kMRT_Channel_0, 22000);&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; //100us interrupt&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_StartTimer(MRT0, kMRT_Channel_1, 220000); //1ms interrupt&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ISR is as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;void MRT0_IRQHandler(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(MRT_GetStatusFlags(MRT0, kMRT_Channel_0))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;MRT_ClearStatusFlags(MRT0, kMRT_Channel_0, kMRT_TimerInterruptFlag);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;APP_LED_TOGGLE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if (MRT_GetStatusFlags(MRT0, kMRT_Channel_1))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;MRT_ClearStatusFlags(MRT0, kMRT_Channel_1, kMRT_TimerInterruptFlag);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;APP_LED_TOGGLE_1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping&lt;BR /&gt;&amp;nbsp; exception return operation might vector to incorrect interrupt */&lt;BR /&gt;#if defined __CORTEX_M &amp;amp;&amp;amp; (__CORTEX_M == 4U)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __DSB();&lt;BR /&gt;#endif&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;regards,&lt;BR /&gt;Hemanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Jul 2020 08:42:28 GMT</pubDate>
    <dc:creator>hemanthvasista</dc:creator>
    <dc:date>2020-07-23T08:42:28Z</dc:date>
    <item>
      <title>Error in Multi-Rate Timer (MRT) with multiple channel</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Error-in-Multi-Rate-Timer-MRT-with-multiple-channel/m-p/1081290#M41536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working on the LPC546xx based device. I tried using Multi-Rate Timer (MRT) with multiple channel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I configure either of one channel, they work fine individually. &lt;BR /&gt;But when I enable both channel, channel-0 is interrupted at different time and no interrupt is generated on channel-1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is code snippet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* mrtConfig.enableMultiTask = false; */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_GetDefaultConfig(&amp;amp;mrtConfig);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Init mrt module */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_Init(MRT0, &amp;amp;mrtConfig);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Setup Channel 0 to be repeated */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_SetupChannelMode(MRT0, kMRT_Channel_0, kMRT_RepeatMode);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_SetupChannelMode(MRT0, kMRT_Channel_1, kMRT_RepeatMode);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Enable timer interrupts for channel 0 */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_EnableInterrupts(MRT0, kMRT_Channel_0, kMRT_TimerInterruptEnable);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_EnableInterrupts(MRT0, kMRT_Channel_1, kMRT_TimerInterruptEnable);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Enable at the NVIC */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EnableIRQ(MRT0_IRQn);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_StartTimer(MRT0, kMRT_Channel_0, 22000);&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; //100us interrupt&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MRT_StartTimer(MRT0, kMRT_Channel_1, 220000); //1ms interrupt&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ISR is as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;void MRT0_IRQHandler(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(MRT_GetStatusFlags(MRT0, kMRT_Channel_0))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;MRT_ClearStatusFlags(MRT0, kMRT_Channel_0, kMRT_TimerInterruptFlag);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;APP_LED_TOGGLE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else if (MRT_GetStatusFlags(MRT0, kMRT_Channel_1))&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;MRT_ClearStatusFlags(MRT0, kMRT_Channel_1, kMRT_TimerInterruptFlag);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;APP_LED_TOGGLE_1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping&lt;BR /&gt;&amp;nbsp; exception return operation might vector to incorrect interrupt */&lt;BR /&gt;#if defined __CORTEX_M &amp;amp;&amp;amp; (__CORTEX_M == 4U)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __DSB();&lt;BR /&gt;#endif&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;regards,&lt;BR /&gt;Hemanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2020 08:42:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Error-in-Multi-Rate-Timer-MRT-with-multiple-channel/m-p/1081290#M41536</guid>
      <dc:creator>hemanthvasista</dc:creator>
      <dc:date>2020-07-23T08:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Error in Multi-Rate Timer (MRT) with multiple channel</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Error-in-Multi-Rate-Timer-MRT-with-multiple-channel/m-p/1081291#M41537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;SPAN class=""&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" class="" data-avatarid="-1" data-content-finding="Community" data-userid="342706" data-username="hemanthvasista@gmail.com" href="https://community.nxp.com/people/hemanthvasista@gmail.com"&gt;Hemanth S&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another thing I can suggest is to do this comparison in the "if" sentence&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;EM&gt;If( 0x3 == MRT_GetStatusFlags(MRT0, kMRT_Channel_0) )&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this is helpful, if you have more questions do not hesitate to ask me.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Omar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jul 2020 17:42:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Error-in-Multi-Rate-Timer-MRT-with-multiple-channel/m-p/1081291#M41537</guid>
      <dc:creator>Omar_Anguiano</dc:creator>
      <dc:date>2020-07-28T17:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: Error in Multi-Rate Timer (MRT) with multiple channel</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Error-in-Multi-Rate-Timer-MRT-with-multiple-channel/m-p/1081292#M41538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for you inputs Omar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add of the below line solved the issue:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;EM&gt;If( 0x3 == MRT_GetStatusFlags(MRT0, kMRT_Channel_0) )&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Hemanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2020 06:35:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Error-in-Multi-Rate-Timer-MRT-with-multiple-channel/m-p/1081292#M41538</guid>
      <dc:creator>hemanthvasista</dc:creator>
      <dc:date>2020-07-29T06:35:34Z</dc:date>
    </item>
  </channel>
</rss>

