<?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>MQX Software Solutions中的主题 Re: using lwevents in an ISR</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/using-lwevents-in-an-ISR/m-p/227599#M6164</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I could not get event flags or semaphores to work correctly from the ISR. What I was wondering was whether the reason they would work was there is nothing to pause in an ISR?? The debounce task could be paused but there was no event/semaphore mechanism to syc the isr and cause it to suspend until the debounce task was resumed. I agree any wait in an ISR could be a fatal mistake.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I got this to work by creating a debounce task. In the ISR disable interrupts, then enable the selection of the specific switch in the debounce task via a flag I set in the ISR. Then re-enable the IRQ's in the debounce task, and once the debounce was complete.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply and advice&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Nov 2013 20:23:18 GMT</pubDate>
    <dc:creator>Cdn_aye</dc:creator>
    <dc:date>2013-11-28T20:23:18Z</dc:date>
    <item>
      <title>using lwevents in an ISR</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/using-lwevents-in-an-ISR/m-p/227597#M6162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to debounce a switch on a GPIO port. I tried using waiting on a semaphore, having a task post (release) the semaphore after the debounce time but that doesn't seem to work in an ISR. Which I guess is reasonable because it seems that the task scheduler interacts with the semaphore calls and the ISR is not a task... or is this an error on my side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I considered lwevents but I think they are plagued by the same problem. Is there 'best practice' someone could recommend for syncing the ISR to the debounced IRQ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the GPIO ISR&lt;/P&gt;&lt;P&gt;Interrupt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; process&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wait on semaphore or event&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resume&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clear interrupt flag&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Debounce Task&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; post semaphore or event to ISR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; time wait (ticks)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or should I just&lt;/P&gt;&lt;P&gt;ISR&lt;/P&gt;&lt;P&gt;diasable the interrupts&lt;/P&gt;&lt;P&gt;wait for the debounce task to run,&lt;/P&gt;&lt;P&gt;delay,&lt;/P&gt;&lt;P&gt;re-enable interrupts to ISR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can probably get the last method to work but it is not very elegant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Nov 2013 04:27:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/using-lwevents-in-an-ISR/m-p/227597#M6162</guid>
      <dc:creator>Cdn_aye</dc:creator>
      <dc:date>2013-11-26T04:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: using lwevents in an ISR</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/using-lwevents-in-an-ISR/m-p/227598#M6163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't be waiting inside an ISR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are going to have the pin trigger an interrupt then typical practice would be for the ISR to post an event to let the task know that the pin state has changed. In the task, block waiting for the event. When you get it, maybe wait for a short time then read the pin state. If it is still asserted, post an event to whatever other tasks need it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have more than one input to scan (e.g. a keypad) then a more typical approach might be to just have the task scan all the keys say every 10ms. For each input have it maintain a record of the current physical state, the current logical state, and some counters. One of the counters would be the debounce counter; the logical state can change after the physical state has been constant for a short time. Other counters would handle short and long presses, auto-repeat, etc. The task can scan the inputs, post whatever events it has determined have happened, then sleep until the next scan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Nov 2013 01:36:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/using-lwevents-in-an-ISR/m-p/227598#M6163</guid>
      <dc:creator>matthewkendall</dc:creator>
      <dc:date>2013-11-28T01:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: using lwevents in an ISR</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/using-lwevents-in-an-ISR/m-p/227599#M6164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I could not get event flags or semaphores to work correctly from the ISR. What I was wondering was whether the reason they would work was there is nothing to pause in an ISR?? The debounce task could be paused but there was no event/semaphore mechanism to syc the isr and cause it to suspend until the debounce task was resumed. I agree any wait in an ISR could be a fatal mistake.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I got this to work by creating a debounce task. In the ISR disable interrupts, then enable the selection of the specific switch in the debounce task via a flag I set in the ISR. Then re-enable the IRQ's in the debounce task, and once the debounce was complete.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply and advice&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Nov 2013 20:23:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/using-lwevents-in-an-ISR/m-p/227599#M6164</guid>
      <dc:creator>Cdn_aye</dc:creator>
      <dc:date>2013-11-28T20:23:18Z</dc:date>
    </item>
  </channel>
</rss>

