<?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>LPC MicrocontrollersのトピックLPC1768 TIM strange behavior when STOP and RESET is requested at match event without ever erasing the IRQ flag</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-TIM-strange-behavior-when-STOP-and-RESET-is-requested-at/m-p/517935#M2416</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by 0xdeadbeef on Wed Apr 23 11:20:42 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;In a project I'm using a timer like this (my own code looks different due to macros etc, but functionally this should be identical):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;MR0 = 6000; // match at 6000 ticks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;IR = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // clear MR0 interrupt flag&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;CTCR = 0;&amp;nbsp;&amp;nbsp; // timer mode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;MCR = 7;&amp;nbsp;&amp;nbsp;&amp;nbsp; // interrupt on match, stop timer on match, reset timer on match&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;TCR = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enable timer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that in my real program, the write access to TCR to start the timer is done via DMA.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Furthermore, the interrupt request actually triggers another DMA transfer, so there is no interrupt handler and the interrupt request flag is never cleared.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now while this seems to work exactly as expected, I have cases where I want to update the match register.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To do this in a safe way, I first disable the DMA transfer that could restart the timer. Then I want to make sure that the last match already happened by&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;waiting until the timer is stopped/reset (note that I can't use the interrupt flag as this is always set due to the absence of an interrupt service routine).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the manual, the enable bit in TCR should be erased and TC should be 0 after the match:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Stop on MR0: the TC and PC will be stopped and TCR[0] will be set to 0 if MR0 matches the TC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Reset on MR0: the TC will be reset if MR0 matches it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However when I try to poll for either ((TCR1 &amp;amp; 1) == 0) [timer was disabled] or (TC==0) [timer was reset], I'm stuck in an endless loop sooner or later.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I break there, I can see that the TC==MR0==6000 and TCR=1. So the match occurred and TC is not changing anymore, but neither was the timer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;reset nor was the enable bit erased - even though the timer is obviously stopped.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Only when I also erase the interrupt service flag inside my polling loop, the enable bit is really always erased.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even then though, the TC is not (always) reset and I have to do it manually to avoid hangups.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't find any hint in the manual that there reset/stop is only correctly performed when the IR flag is reset or that the combination of STOP and RESET&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;doesn't work reliably. So is this a flaw or the way it should be???&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:30:51 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:30:51Z</dc:date>
    <item>
      <title>LPC1768 TIM strange behavior when STOP and RESET is requested at match event without ever erasing the IRQ flag</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-TIM-strange-behavior-when-STOP-and-RESET-is-requested-at/m-p/517935#M2416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by 0xdeadbeef on Wed Apr 23 11:20:42 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;In a project I'm using a timer like this (my own code looks different due to macros etc, but functionally this should be identical):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;MR0 = 6000; // match at 6000 ticks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;IR = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // clear MR0 interrupt flag&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;CTCR = 0;&amp;nbsp;&amp;nbsp; // timer mode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;MCR = 7;&amp;nbsp;&amp;nbsp;&amp;nbsp; // interrupt on match, stop timer on match, reset timer on match&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TIM3-&amp;gt;TCR = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enable timer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that in my real program, the write access to TCR to start the timer is done via DMA.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Furthermore, the interrupt request actually triggers another DMA transfer, so there is no interrupt handler and the interrupt request flag is never cleared.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now while this seems to work exactly as expected, I have cases where I want to update the match register.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To do this in a safe way, I first disable the DMA transfer that could restart the timer. Then I want to make sure that the last match already happened by&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;waiting until the timer is stopped/reset (note that I can't use the interrupt flag as this is always set due to the absence of an interrupt service routine).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the manual, the enable bit in TCR should be erased and TC should be 0 after the match:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Stop on MR0: the TC and PC will be stopped and TCR[0] will be set to 0 if MR0 matches the TC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Reset on MR0: the TC will be reset if MR0 matches it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However when I try to poll for either ((TCR1 &amp;amp; 1) == 0) [timer was disabled] or (TC==0) [timer was reset], I'm stuck in an endless loop sooner or later.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I break there, I can see that the TC==MR0==6000 and TCR=1. So the match occurred and TC is not changing anymore, but neither was the timer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;reset nor was the enable bit erased - even though the timer is obviously stopped.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Only when I also erase the interrupt service flag inside my polling loop, the enable bit is really always erased.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even then though, the TC is not (always) reset and I have to do it manually to avoid hangups.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't find any hint in the manual that there reset/stop is only correctly performed when the IR flag is reset or that the combination of STOP and RESET&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;doesn't work reliably. So is this a flaw or the way it should be???&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:30:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-TIM-strange-behavior-when-STOP-and-RESET-is-requested-at/m-p/517935#M2416</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768 TIM strange behavior when STOP and RESET is requested at match event without ever erasing the IRQ flag</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-TIM-strange-behavior-when-STOP-and-RESET-is-requested-at/m-p/517936#M2417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by wmues on Wed Apr 23 23:57:52 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I do not know if "stop timer on match" and "reset timer on match" are designed so that they can be used together.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try to use only "stop timer on match". You can reset the timer per software later.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you tried to clear the interrupt service flag via DMA?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wolfgang&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:30:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-TIM-strange-behavior-when-STOP-and-RESET-is-requested-at/m-p/517936#M2417</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768 TIM strange behavior when STOP and RESET is requested at match event without ever erasing the IRQ flag</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-TIM-strange-behavior-when-STOP-and-RESET-is-requested-at/m-p/517937#M2418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by 0xdeadbeef on Thu Apr 24 10:14:23 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: wmues&lt;/STRONG&gt;&lt;BR /&gt;I do not know if "stop timer on match" and "reset timer on match" are designed so that they can be used together.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, they should. At least I need that to work for my usecase. I wouldn't care if the timer is only reset after it is started again (which I assume is what happens during normal operation).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: wmues&lt;/STRONG&gt;&lt;BR /&gt;Try to use only "stop timer on match". You can reset the timer per software later.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is no need for this as the timer itself works as expected. It's just that polling for the timer being stopped doesn't work as it should - which I only need to avoid inconsistencies during period updates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: wmues&lt;/STRONG&gt;&lt;BR /&gt;Have you tried to clear the interrupt service flag via DMA?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't see really how this would help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In a nutshell: I don't want to fiddle with other workarounds. I want to know why the TIM peripheral doesn't work as described in the manual or if I'm missing some details. The intention is to implement a solution that will always work - not one that works by chance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:30:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-TIM-strange-behavior-when-STOP-and-RESET-is-requested-at/m-p/517937#M2418</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:30:52Z</dc:date>
    </item>
  </channel>
</rss>

