<?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 LPC55S16 ADC with multiple trigger commands in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1386507#M47375</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have some trouble with the ADC on the LPC55S16.&lt;/P&gt;&lt;P&gt;Our usecase:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Using the internal temperature&lt;/LI&gt;&lt;LI&gt;Using several ADC channels, both A side and B side (all in single ended mode).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For easy integrating in our current codebase, we want to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Have a trigger command for each individual ADC channel&lt;/LI&gt;&lt;LI&gt;Trigger the command individually (by our SW)&lt;/LI&gt;&lt;LI&gt;Use polling to get the ADC result.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;When I implemented this, the ADC values were jumping all over the place, like&amp;nbsp;they ended up in the wrong (random) ADC variables.&lt;/P&gt;&lt;P&gt;E.g.: when I did 3 channels (ADC0, ADC1, ADC2), the results were like:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;valueADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;valueADC1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;valueADC2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried to reproduce this on me LPCXpresso55S16 development board.&lt;BR /&gt;I used the&amp;nbsp;lpadc_temperature_measurement example as basis, with the following changes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I removed the GETCHAR() macro, and replaced it with a 1 second delay (to get results continuously, like in our application)&lt;/LI&gt;&lt;LI&gt;Removed the interrupt handling, and made it polling (copied from lpadc_polling example)&lt;/LI&gt;&lt;LI&gt;Used the CommandID also as TriggerID (so I could easily distinguish later between several ADC channels)&lt;/LI&gt;&lt;LI&gt;Created a seperate function for the channel configuration, which I could easily copy later on for other channels.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;After those changes the example still worked correctly (although temperature measurement needs some additional work, as there is a lot of digital noise due to low resolution of the vbe ADC values, but that's another topic):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="janpieterderuit_0-1639489562559.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/165143i9056A93B15C15D50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="janpieterderuit_0-1639489562559.png" alt="janpieterderuit_0-1639489562559.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now I added ADC channel ADC0_0 (PIO0_23):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Added pin config in pinmux.c (copied from lpadc_polling example)&lt;/LI&gt;&lt;LI&gt;Copied the Temperature sensor config function (mentioned above), and changed it for ADC0_0:&lt;UL&gt;&lt;LI&gt;channelNumber = 0&lt;/LI&gt;&lt;LI&gt;sampleChannelMode =&amp;nbsp;kLPADC_SampleChannelSingleEndSideA&lt;/LI&gt;&lt;LI&gt;New CommandID (2) and also use it as triggerID&lt;/LI&gt;&lt;LI&gt;loopCount = 0&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;After the Temperature sensor trigger and getting the temperature, I added a new trigger (LPADC_DoSoftwareTrigger) with the new triggerID (mask).&lt;/LI&gt;&lt;LI&gt;Added the result to the terminal output.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This is what I get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="janpieterderuit_1-1639490158376.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/165144i354FBF30F3853C99/image-size/medium?v=v2&amp;amp;px=400" role="button" title="janpieterderuit_1-1639490158376.png" alt="janpieterderuit_1-1639490158376.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see the first temperature result looks OK, but after that it's way off.&lt;BR /&gt;(I didn't check the ADC0_0 result, but that also looks off, as nothing is connected to the pin yet)&lt;/P&gt;&lt;P&gt;I attached my MCUXpresso project, can you please have a look what I'm doing wrong?&lt;BR /&gt;I can't find any example using multiple channels or ADC commands.&lt;BR /&gt;I can't figure it out...&lt;BR /&gt;It looks like there's something going wrong in the FIFO, but I can only see the top value...&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
    <pubDate>Tue, 14 Dec 2021 14:42:21 GMT</pubDate>
    <dc:creator>janpieterderuit</dc:creator>
    <dc:date>2021-12-14T14:42:21Z</dc:date>
    <item>
      <title>LPC55S16 ADC with multiple trigger commands</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1386507#M47375</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have some trouble with the ADC on the LPC55S16.&lt;/P&gt;&lt;P&gt;Our usecase:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Using the internal temperature&lt;/LI&gt;&lt;LI&gt;Using several ADC channels, both A side and B side (all in single ended mode).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For easy integrating in our current codebase, we want to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Have a trigger command for each individual ADC channel&lt;/LI&gt;&lt;LI&gt;Trigger the command individually (by our SW)&lt;/LI&gt;&lt;LI&gt;Use polling to get the ADC result.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;When I implemented this, the ADC values were jumping all over the place, like&amp;nbsp;they ended up in the wrong (random) ADC variables.&lt;/P&gt;&lt;P&gt;E.g.: when I did 3 channels (ADC0, ADC1, ADC2), the results were like:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;valueADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;valueADC1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;valueADC2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC0&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;ADC1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried to reproduce this on me LPCXpresso55S16 development board.&lt;BR /&gt;I used the&amp;nbsp;lpadc_temperature_measurement example as basis, with the following changes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I removed the GETCHAR() macro, and replaced it with a 1 second delay (to get results continuously, like in our application)&lt;/LI&gt;&lt;LI&gt;Removed the interrupt handling, and made it polling (copied from lpadc_polling example)&lt;/LI&gt;&lt;LI&gt;Used the CommandID also as TriggerID (so I could easily distinguish later between several ADC channels)&lt;/LI&gt;&lt;LI&gt;Created a seperate function for the channel configuration, which I could easily copy later on for other channels.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;After those changes the example still worked correctly (although temperature measurement needs some additional work, as there is a lot of digital noise due to low resolution of the vbe ADC values, but that's another topic):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="janpieterderuit_0-1639489562559.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/165143i9056A93B15C15D50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="janpieterderuit_0-1639489562559.png" alt="janpieterderuit_0-1639489562559.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now I added ADC channel ADC0_0 (PIO0_23):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Added pin config in pinmux.c (copied from lpadc_polling example)&lt;/LI&gt;&lt;LI&gt;Copied the Temperature sensor config function (mentioned above), and changed it for ADC0_0:&lt;UL&gt;&lt;LI&gt;channelNumber = 0&lt;/LI&gt;&lt;LI&gt;sampleChannelMode =&amp;nbsp;kLPADC_SampleChannelSingleEndSideA&lt;/LI&gt;&lt;LI&gt;New CommandID (2) and also use it as triggerID&lt;/LI&gt;&lt;LI&gt;loopCount = 0&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;After the Temperature sensor trigger and getting the temperature, I added a new trigger (LPADC_DoSoftwareTrigger) with the new triggerID (mask).&lt;/LI&gt;&lt;LI&gt;Added the result to the terminal output.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This is what I get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="janpieterderuit_1-1639490158376.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/165144i354FBF30F3853C99/image-size/medium?v=v2&amp;amp;px=400" role="button" title="janpieterderuit_1-1639490158376.png" alt="janpieterderuit_1-1639490158376.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see the first temperature result looks OK, but after that it's way off.&lt;BR /&gt;(I didn't check the ADC0_0 result, but that also looks off, as nothing is connected to the pin yet)&lt;/P&gt;&lt;P&gt;I attached my MCUXpresso project, can you please have a look what I'm doing wrong?&lt;BR /&gt;I can't find any example using multiple channels or ADC commands.&lt;BR /&gt;I can't figure it out...&lt;BR /&gt;It looks like there's something going wrong in the FIFO, but I can only see the top value...&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 14:42:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1386507#M47375</guid>
      <dc:creator>janpieterderuit</dc:creator>
      <dc:date>2021-12-14T14:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55S16 ADC with multiple trigger commands</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1388022#M47400</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;There is Multiple ADC demo you can compare to have a look :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/ADC-multi-channel-sampling-and-DMA-transfer-in-LPC55xx/ta-p/1304608" target="_blank"&gt;https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/ADC-multi-channel-sampling-and-DMA-transfer-in-LPC55xx/ta-p/1304608&lt;/A&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 09:29:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1388022#M47400</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2021-12-16T09:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55S16 ADC with multiple trigger commands</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1388057#M47401</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thanks, I found that one indeed.&lt;BR /&gt;But:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;It does several measurements in one trigger, while we want individual triggers for each measurement&lt;/LI&gt;&lt;LI&gt;It doesn't include internal temperature measurement (and I suspect it's related to that)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;BR, Jan Pieter&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 10:17:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1388057#M47401</guid>
      <dc:creator>janpieterderuit</dc:creator>
      <dc:date>2021-12-16T10:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55S16 ADC with multiple trigger commands</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1390559#M47449</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;You said want individual triggers for each measurement, from your&amp;nbsp; result , I think in your project, one triggered three channels. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 06:41:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1390559#M47449</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2021-12-22T06:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: LPC55S16 ADC with multiple trigger commands</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1390914#M47460</link>
      <description>&lt;P&gt;Hi Alice,&lt;/P&gt;&lt;P&gt;thanks for your reply.&lt;/P&gt;&lt;P&gt;In my example I have different commands and triggers for each channel, and I also do call seperate triggers.&lt;/P&gt;&lt;P&gt;Anyway, I found the issue:&lt;BR /&gt;in the past we found that a trigger was missed somehow occasionally.&lt;BR /&gt;This resulted in an infinite wait for the conversion result (with ultimately a watchdog reset).&lt;/P&gt;&lt;P&gt;We fixed this by adding a timeout for the while loop which gets the conversion result.&lt;BR /&gt;We set the timeout max at 255 cycles, which is good enough for normal ADC measurements.&lt;/P&gt;&lt;P&gt;However, I found that the internal temperature measurement can take about 4500 cycles (CPU running at 96MHz and ADC clock of 4MHz).&lt;BR /&gt;I suppose this is probably because of the hardware averaging used by the internal temperature measurement (we do not do HW averaging on the normal ADC measurements).&lt;/P&gt;&lt;P&gt;So the conversion while loop for the internal temp measurement was aborted due to the timeout, but the FIFO was later on still filled with the temperature values (vbe1/vbe8).&lt;BR /&gt;And those values ended up later on when the normal ADC channel measurement is triggered.&lt;/P&gt;&lt;P&gt;I now fixed it by increasing the timeout max to 10000.&lt;/P&gt;&lt;P&gt;Thanks for your effort.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 20:35:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S16-ADC-with-multiple-trigger-commands/m-p/1390914#M47460</guid>
      <dc:creator>janpieterderuit</dc:creator>
      <dc:date>2021-12-22T20:35:04Z</dc:date>
    </item>
  </channel>
</rss>

