<?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: KEA ADC overrun misaligns internal FIFO in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601403#M35289</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Code and screen shot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Mar 2017 08:01:24 GMT</pubDate>
    <dc:creator>phil74</dc:creator>
    <dc:date>2017-03-01T08:01:24Z</dc:date>
    <item>
      <title>KEA ADC overrun misaligns internal FIFO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601396#M35282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;In order to evaluate the ADC of this MCU I wrote a simple test software to continuously read out one ADC channel (see attachment “main.c”).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;I use the FIFO feature of the ADC to always get 8 samples at once per ISR call. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Actually this code works well as long as no overrun occurs in the ADC FIFO (or in other words, as long as I always read the “ADC_R” register before the next ADC sample is available).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;But if for some reason I lose at least one ADC sample (FIFO overrun occurs, for example due to a higher priority ISR), the FIFO seems to be out of sync for all future reads. So from this time on, I always get the 8 ADC samples in a wrong order when reading the “ADC_R” register.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;The datasheet says that if FIFO is full, &lt;EM&gt;then the next conversion will override old data in case of no read action. &lt;/EM&gt;&lt;BR /&gt;This is fine, but it seems then that the internal FIFO pointer has been shifted even for the next interrupts... &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;---&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;For better understanding, I have attached some pictures of my measurement:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI style="text-indent: -18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;“scope_1.png” shows the signals on the MCU pins PTC0 (AD8) and PTE0 (“SCOPE_PIN” in the sample code)&lt;/SPAN&gt;&lt;UL&gt;&lt;LI style="margin-left: 72.0pt; text-indent: -18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Green line: Waveform on the ADC input pin (sawtooth from a waveform generator)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="margin-left: 72.0pt; text-indent: -18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Yellow line: Activity of the ADC ISR (low = background task, high = ISR processing).&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI style="text-indent: -18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;“values_1.png” shows the measured ADC values&lt;/SPAN&gt;&lt;UL&gt;&lt;LI style="margin-left: 72.0pt; text-indent: -18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Gray bars: Count of ADC values fetched in the ISR (array “adc_count_buffer”)&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="margin-left: 72.0pt; text-indent: -18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Red dots: Measured ADC values (array “adc_buffer” which was filled by reading the FIFO register “ADC_R”)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;As you can see, I have simulated a FIFO overrun in the middle of the measurement with a short busy wait in the ADC ISR. Before this overrun, all ADC values are correct, but after it the order of the ADC samples is wrong. This makes it impossible to design a robust and reliable firmware, because losing one single ADC sample can lead to permanently wrong ADC results in future.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Do you have an idea what’s going wrong here and how I can avoid this? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Thanks in advance,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;BR,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Philippe&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Dec 2016 16:32:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601396#M35282</guid>
      <dc:creator>phil74</dc:creator>
      <dc:date>2016-12-12T16:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: KEA ADC overrun misaligns internal FIFO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601397#M35283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;Can you set the ASCANE bit in ADC_SC4 register and have a try? If you set the bit, the FIFO always use the first dummied FIFO channels when it is enabled.&lt;/P&gt;&lt;P&gt;If the above method can not fix the issue, as a workaround, you can write 0x1F to ADCH bits in ADC_SC1 register to reset the FIFO when overrun event happens.&lt;/P&gt;&lt;P&gt;BTW, I can not see the scope_1.png and values_1.png you submitted.&lt;/P&gt;&lt;P&gt;Hope it can help you.&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;XiangJun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 03:16:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601397#M35283</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2016-12-13T03:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: KEA ADC overrun misaligns internal FIFO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601398#M35284</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;&lt;SPAN style="font-size: 10.0pt; color: #1f497d;"&gt;Unfortunately the ASCANE bit did not change anything, so the problem still exists.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #1f497d;"&gt;And detecting an overrun is not possible (unexpected interrupt can arrive anytime), so I don’t know when I have to reset the FIFO...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #1f497d;"&gt;Do you have any other recommandation ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #1f497d;"&gt;BR,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #1f497d;"&gt;Philippe.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #1f497d;"&gt;Note : I insert the 2 screeshot that you could not read.&lt;span class="lia-inline-image-display-wrapper" image-alt="scope_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/11442iB3711308392A5A3C/image-size/large?v=v2&amp;amp;px=999" role="button" title="scope_1.png" alt="scope_1.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #1f497d;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="values_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/11494iFBAC37253E106D3C/image-size/large?v=v2&amp;amp;px=999" role="button" title="values_1.png" alt="values_1.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 13:51:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601398#M35284</guid>
      <dc:creator>phil74</dc:creator>
      <dc:date>2016-12-13T13:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: KEA ADC overrun misaligns internal FIFO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601399#M35285</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;Any feedback?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Philippe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Dec 2016 07:53:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601399#M35285</guid>
      <dc:creator>phil74</dc:creator>
      <dc:date>2016-12-19T07:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: KEA ADC overrun misaligns internal FIFO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601400#M35286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 15px;"&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #1f497d; font-family: arial,helvetica,sans-serif;"&gt;This issue looks like a hardware bug in the FIFO?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #1f497d; font-family: arial,helvetica,sans-serif;"&gt;Can confirm this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #1f497d; font-family: arial,helvetica,sans-serif;"&gt;BR,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 15px; color: #1f497d; font-family: arial,helvetica,sans-serif;"&gt;Philippe&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2016 09:17:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601400#M35286</guid>
      <dc:creator>phil74</dc:creator>
      <dc:date>2016-12-21T09:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: KEA ADC overrun misaligns internal FIFO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601401#M35287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Phil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;could you please share your main.c file, is not attached in thread.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Ricardo Olivares&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2017 02:30:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601401#M35287</guid>
      <dc:creator>ricardoolivare1</dc:creator>
      <dc:date>2017-02-28T02:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: KEA ADC overrun misaligns internal FIFO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601402#M35288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ricardo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is included in the zip file I have sent you by mail.&lt;/P&gt;&lt;P&gt;Anyway, here is it.&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Philippe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Mar 2017 07:55:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601402#M35288</guid>
      <dc:creator>phil74</dc:creator>
      <dc:date>2017-03-01T07:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: KEA ADC overrun misaligns internal FIFO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601403#M35289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Code and screen shot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Mar 2017 08:01:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601403#M35289</guid>
      <dc:creator>phil74</dc:creator>
      <dc:date>2017-03-01T08:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: KEA ADC overrun misaligns internal FIFO</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601404#M35290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This definitely looks like a hardware bug.&lt;/P&gt;&lt;P&gt;The oldest conversion gets overwritten by the new conversion, but the front of the FIFO&amp;nbsp;does not get updated.&lt;/P&gt;&lt;P&gt;To avoid this you probably have to set the ADC as the highest priority interrupt.&lt;/P&gt;&lt;P&gt;Alternatively you can try to use the DMA to transfer the FIFO ta a local buffer.&lt;/P&gt;&lt;P&gt;If those are not feasible and you don't mind losing samples you need to check the overrun flag each time the FIFO is going to be read and empty it if the overrun flag is set.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Apr 2018 13:57:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEA-ADC-overrun-misaligns-internal-FIFO/m-p/601404#M35290</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2018-04-09T13:57:47Z</dc:date>
    </item>
  </channel>
</rss>

