<?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 Re: user-defined ISR and FIFO queues in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/user-defined-ISR-and-FIFO-queues/m-p/183468#M3005</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello emilien,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;If you are feeding (circular) buffer, the feeding is not atomic. That's why you can get into not consistent state if 2 concurrent pieces of code are modifying buffer pointers (producer and consumer pointers) and feeding data with buffers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have to keep in mind that low priority task handling buffer can be interrupted with high priority interrupt handling the same buffer. The easiest synchronization is: to disable interrupt in the task - modify buffer - enable interrupt and deffer ISR.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even if access to the head/teal is atomic, still be careful about the code order. Check the status (empty/full), fill the data, update index. Probably buffer needs one empty space to be used (Size-1 used) for a situation head=tail (is empty or full?).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MartinK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jul 2012 13:24:43 GMT</pubDate>
    <dc:creator>c0170</dc:creator>
    <dc:date>2012-07-31T13:24:43Z</dc:date>
    <item>
      <title>user-defined ISR and FIFO queues</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/user-defined-ISR-and-FIFO-queues/m-p/183467#M3004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I need some advice with my software design:&lt;/P&gt;&lt;P&gt;My ADCs are constantly feeding a buffer. Because I needed responsiveness, I don't use MQX interrupts and I installed user-defined interrupts instead. Some other task will read in the ADC buffer and apply filtering. This buffer is fixed size and I'm not sure if I will drop data that would cause overflow or if I will make the buffer circular.&lt;/P&gt;&lt;P&gt;In the end I think this is more or less a producer/consumer issue, with my ADCs interrupts being producers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What kind of task synchronization tool would you choose? I could see that lightweight events are used to signal interrupts to tasks, but I think in my case lightweight semaphores would be appropriate, what do you think? I'm looking at the MQX examples but if you know a good way to achieve this it would be helpful : )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Emilien&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 15:31:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/user-defined-ISR-and-FIFO-queues/m-p/183467#M3004</guid>
      <dc:creator>emilien</dc:creator>
      <dc:date>2012-07-26T15:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: user-defined ISR and FIFO queues</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/user-defined-ISR-and-FIFO-queues/m-p/183468#M3005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello emilien,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;If you are feeding (circular) buffer, the feeding is not atomic. That's why you can get into not consistent state if 2 concurrent pieces of code are modifying buffer pointers (producer and consumer pointers) and feeding data with buffers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have to keep in mind that low priority task handling buffer can be interrupted with high priority interrupt handling the same buffer. The easiest synchronization is: to disable interrupt in the task - modify buffer - enable interrupt and deffer ISR.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even if access to the head/teal is atomic, still be careful about the code order. Check the status (empty/full), fill the data, update index. Probably buffer needs one empty space to be used (Size-1 used) for a situation head=tail (is empty or full?).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MartinK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2012 13:24:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/user-defined-ISR-and-FIFO-queues/m-p/183468#M3005</guid>
      <dc:creator>c0170</dc:creator>
      <dc:date>2012-07-31T13:24:43Z</dc:date>
    </item>
  </channel>
</rss>

