<?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: A/D Driver Unable to Open Channel</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190753#M3675</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello joey81,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suggest you to look for lwadc in another bsp to find out all places which you should change in your bsp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's take an example from TWRPXN20 bsp to highlight all lwadc related declarations/definitions, there's init_lwadc file where is definition of lwadc structure, create this structure according to your board.&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13612557984845534" jivemacro_uid="_13612557984845534"&gt;
&lt;P&gt;const LWADC_INIT_STRUCT lwadc0_init = { 0, LWADC_FORMAT_RIGHT_JUSTIFIED, BSP_PERI3_CLOCK, BSP_ADC_VREF_DEFAULT };&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;includes in bsp header file&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_13612557294259840 jive_macro_code" jivemacro_uid="_13612557294259840"&gt;
&lt;P&gt;#include &amp;lt;lwadc_mpxnxx.h&amp;gt;&lt;/P&gt;
&lt;P&gt;#include &amp;lt;lwadc_mpxn20.h&amp;gt;&lt;/P&gt;
&lt;P&gt;#include &amp;lt;lwadc.h&amp;gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;bsp_prv header file declares extern structure&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13612557293426706" jivemacro_uid="_13612557293426706"&gt;
&lt;P&gt;extern const LWADC_INIT_STRUCT lwadc0_init;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's conditionaly compiled code in init_bsp code file&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13612557293219777" jivemacro_uid="_13612557293219777"&gt;
&lt;P&gt;#if BSPCFG_ENABLE_LWADC&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;#if BSPCFG_ENABLE_LWADC0&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; _lwadc_init(&amp;amp;lwadc0_init);&amp;nbsp; &lt;/P&gt;
&lt;P&gt;#endif&lt;/P&gt;
&lt;P&gt;#endif&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Last file is the board header which should contain all macros which are used in the driver (check LWADC DRIVER CONFIGURATION). The next step is to customize lwadc driver ( create your own lwadc_k60 file because I believe there is more than just one ADC module).&lt;/P&gt;&lt;P&gt;&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>Thu, 29 Oct 2020 09:42:36 GMT</pubDate>
    <dc:creator>c0170</dc:creator>
    <dc:date>2020-10-29T09:42:36Z</dc:date>
    <item>
      <title>A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190744#M3666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 5 A/D channels all&amp;nbsp;various channels of ADC1.&amp;nbsp; &amp;nbsp;If I try to initialize any channel that is on the ADC1_SOURCE_AD19 or&amp;nbsp;ADC1_SOURCE_AD20&amp;nbsp; the system comes back with a failed attempt.&amp;nbsp; If I try ADC1_SOURCE_AD0 it works just fine.&amp;nbsp; Problem is that I need AD19 and AD20 as that is where the hardware has the values..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to single step through the fopen driver for the ADC to see where the error is.. but the IDE&amp;nbsp;for the debugger keeps crashing on me.&lt;/P&gt;&lt;PRE&gt;#define MY_TRIGGER            ADC_PDB_TRIGGER  //Trigger Used for Every Channel// Logical channel init struct - ADC1_AD19 - EX_ANALOG_1 const ADC_INIT_CHANNEL_STRUCT Ex1_ch_param = {    ADC1_SOURCE_AD19,          // Physical ADC channel    ADC_CHANNEL_MEASURE_LOOP | ADC_CHANNEL_START_TRIGGERED,    // Runs continuously after IOCTL trigger    1,                        // Number of samples in one run sequence    0,                        // Time offset from trigger point in us    100000,                   // Period in us (= 0.1 sec)    0x10000,                  // Scale range of result (not used now)    1,                        // Circular buffer size (sample count)    MY_TRIGGER,               // Logical trigger ID that starts this ADC channel    &amp;amp;adcEvent,                // lwevent Object    ADC_DATA_READY_MASK       // lwevent Mask to be set when complete. };// Logical channel init struct - ADC1_AD0 - Heat Seal  const ADC_INIT_CHANNEL_STRUCT HeatSeal_ch_param = {    ADC1_SOURCE_AD0,         // Physical ADC channel    ADC_CHANNEL_MEASURE_LOOP | ADC_CHANNEL_START_TRIGGERED,    // Runs continuously after IOCTL trigger    1,                        // Number of samples in one run sequence    0,                        // Time offset from trigger point in us    100000,                   // Period in us (= 0.1 sec)    0x10000,                  // Scale range of result (not used now)    1,                        // Circular buffer size (sample count)    MY_TRIGGER,               // Logical trigger ID that starts this ADC channel    NULL,                     // lwevent Object    0                         // lwevent Mask to be set when complete. };   // Open the ADC device   adc = fopen(ADC_STR, (const char*)&amp;amp;adc_init);   if (adc == NULL)   {      printf("\nADC_Task: Open ADC device failed!\n");      _task_block();   }   // Open and Initialize the ADC Channels.    adc_ex1 = fopen(EX1_STR, (const char*)&amp;amp;Ex1_ch_param);   if (adc_ex1 == NULL)   {      printf("\nADC_Task: Open ADC channel for EX1 failed!\n");      //_task_block();   }    // Open and Initialize the ADC Channels.    adc_hs = fopen(HS_STR, (const char*)&amp;amp;HeatSeal_ch_param);   if (adc_hs == NULL)   {      printf("\nADC_Task: Open ADC channel for Heat Seal failed!\n");      // _task_block();   }   ......&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts on my ADC error or the crashing Debugger would be helpful?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FYI.. I'm using a K70 ad the P&amp;amp;E Multilink Universal Debugger under CodeWarrior 10.2 with MQX 3.8.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:42:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190744#M3666</guid>
      <dc:creator>Ali2006</dc:creator>
      <dc:date>2020-10-29T09:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190745#M3667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One More thing..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it true that the MQX driver can only handle 2 channels per ADC block..?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I open more than one block for the same hardware resource?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ADC_MAX_CHANNELS is set to a (2) inside the adc.c files.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Aug 2012 03:11:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190745#M3667</guid>
      <dc:creator>Ali2006</dc:creator>
      <dc:date>2012-08-18T03:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190746#M3668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ali2006,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's not drawback of MQX but hardware. Therefore it's set to 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Open file init_gpio in K70 BSP folder. There are declared 2 adc conversion tables (adc0, adc1). They don't have channels 19 and 20 implemented. I checked K70 reference manual, those 2 channels are not available:&lt;/P&gt;&lt;P&gt;from adc1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADC_SIG_NA,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //19 not implemented&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADC_SIG_NA,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //20 not implemented&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the cause of opening error.&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>Mon, 20 Aug 2012 15:02:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190746#M3668</guid>
      <dc:creator>c0170</dc:creator>
      <dc:date>2012-08-20T15:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190747#M3669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I played with ADC in MQX awhile back.&amp;nbsp; ZIP attached.&amp;nbsp; It is not elegant code but in general what it is doing is the following:&lt;/P&gt;&lt;P&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Infinite loop in main() that is checking to see if a ADC task is running or not.&amp;nbsp; If not it then creates one.&amp;nbsp; Since the ADC task is higher priority it will run to completion and terminate.&lt;/P&gt;&lt;P&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The ADC task that is created temporarily is passed a “channel #” (it really is an index to the adc_channel_paramx definitions).&lt;/P&gt;&lt;P&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The ADC task will open the appropriate ADC module and channel, get a sample, place sample in global variable (ADC_RESULT_STRUCT data&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt; and print it to the terminal.&lt;/P&gt;&lt;P&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The ADC task will close the channel and module, then terminate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I envision being able to create a table of the adc_channel_paramx’s and using DMA interrupts with ADC interrupts to more autonomously and dynamically collect ADC samples.&amp;nbsp; I just haven’t gotten there yet time wise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Customer is correct that it is only two samples per ADC module that can occur.&amp;nbsp; Therefore the above solution.&lt;/P&gt;&lt;P&gt;Note when debugging ADC code you really have to let it fly.&amp;nbsp; Halting the processor does not halt the ADC and once you halt while it is trying to sample it stops trigger properly.&amp;nbsp; I think that has to deal with the debugger reading ADC register that then clears a flag you don’t want cleared.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Aug 2012 23:10:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190747#M3669</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2012-08-20T23:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190748#M3670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Kojto,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I read the K70 Reference manual,&amp;nbsp; the K70 in the 256BGA package is supposed to have 4 ADC modules.. each with the ability to select up to 32 different sources.&amp;nbsp; I have looked again&amp;nbsp;at the ADC1 channel assigments&amp;nbsp; on page 140/141 of the reference manual section 3.7.1.4&amp;nbsp;and &amp;nbsp;I should be able to select channel AD19 and get input signal&amp;nbsp; ADC1_DM0.. and AD19 should give me ADC1_DM1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But.. I have now also looked at the init_gpio as you mentioned and do see the AD19 and AD20 are not implemented.&amp;nbsp;&amp;nbsp;&amp;nbsp; I can see that they probably left them off because as they can be associated with differential channels.. but they are available for use singled ended.. (Unless I'm misreading the manual?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you.. or anyone else, see any reason why I couldn't implement these signals by modifying the init_gpio module to return the ADC_SIG_NC for them.. since they are on pins that "default" to analog?&amp;nbsp;&amp;nbsp;&amp;nbsp; I know I'm just asking for future problems.. but this seems like a start anyway..&amp;nbsp; Does anyone know of any other pitfalls before I get started with this approach? .. Or should I just abandon MQX driver and write my own.?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 08:36:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190748#M3670</guid>
      <dc:creator>Ali2006</dc:creator>
      <dc:date>2012-08-21T08:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190749#M3671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello DavidS,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the sample code.. In reviewing I notice that your version of init_gpio.c Version 3.8.24.0 OCt 7-2011.. actually has AD19 and AD20 implemented in the manner I suggested in my above reply.. Which K device was that from?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, is there a significance to turning ON and OFF the clock module as you do in the _bsp_adc_io_init?&amp;nbsp; Is that to "reset" the modules so that you can reiniitialize for the next channel setup?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 09:09:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190749#M3671</guid>
      <dc:creator>Ali2006</dc:creator>
      <dc:date>2012-08-21T09:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190750#M3672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the question about only 2 conversion of kinetis ADC was asked here before. It's limited by ADCx_SC1x registers. There are only 2, each one for each conversion, therefore number is set to 2 in MQX ADC driver for K70.&amp;nbsp; Read 39.3.1 chapter for more information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked the package of our K70 tower and there should be available those 2 channels ADC. Even some others are not implemented but present in the MCU. It is going to be fixed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What you can do right now is to enable those channels by changing adc tables in init_gpio code file. I suggest you to back up the file before you do any change just for future reference if anything goes wrong. Let us know the result.&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, 21 Aug 2012 14:01:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190750#M3672</guid>
      <dc:creator>c0170</dc:creator>
      <dc:date>2012-08-21T14:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190751#M3673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The LWADC driver in MQX v4.0 has been updated to support Kinetis.&amp;nbsp; The LWADC driver is simpler to use than the Kinetis ADC driver, and it allows more than 2 channels per ADC.&amp;nbsp; The LWADC driver does not use the PDB timer for hardware triggering of the ADC conversion like the ADC driver does.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only Kinetis LWADC example provided in MQX v4.0 is for the TWR-K21D50M BSP, but the LWADC driver can be added to other Kinetis BSPs.&amp;nbsp; The Kinetis LWADC example is configured to only scan 1 ADC channel for the potentiometer on the board.&amp;nbsp; But with some simple changes, the BSP and example code can be modified to enable converting multiple channels.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the BSP, modify twrk21d50m.h to add more ADC channel defines.&amp;nbsp; In my example, I added two more channels for the Tower AN7 and AN6 signals.&amp;nbsp; These are tied to ADC0_SE8 and ADC0_SE9 on the MCU.&amp;nbsp; My twrk21d50m.h file is attached.&amp;nbsp; Also, enable the BSPCFG_ENABLE_LWADC macro in user_config.h, then rebuild the BSP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;#define BSP_ADC_TWR_AN7&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;(ADC0_SOURCE_AD8)&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;#define BSP_ADC_TWR_AN6&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;(ADC0_SOURCE_AD9)&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the example \Freescale_MQX_4_0\mqx\examples\lwadc, I found the application scanned all enabled channels in the BSP, but it did not change the channels in the continuous scan loop.&amp;nbsp; I added calls to _lwadc_init_input() in the infinite scan loop in test.c, also attached.&amp;nbsp; Now with the app rebuilt, it scans 3 ADC channels continuously.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("Monitoring ADC Inputs\n");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (1) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i=0;i&amp;lt;ELEMENTS_OF(adc_inputs);i++) {&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* DAS - Reinitialize to change channel */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( !&lt;SPAN style="color: #0000ff;"&gt;_lwadc_init_input(&amp;amp;lwadc_inputs[i],adc_inputs[i].input)&lt;/SPAN&gt; ) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Failed to initialize this input. We will end up failing the reads below as well. */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("Failed to initialize ADC input %s\n",adc_inputs[i].name);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This waits until a new conversion is read on the channel */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (_lwadc_wait_next(&amp;amp;lwadc_inputs[i])) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (_lwadc_read(&amp;amp;lwadc_inputs[i], &amp;amp;scaled) &amp;amp;&amp;amp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _lwadc_read_raw(&amp;amp;lwadc_inputs[i], &amp;amp;raw)) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Obtained data, is the change significant enough to display? */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delta = (raw&amp;gt;last[i])?raw-last[i]:last[i]-raw;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (delta &amp;gt; max_delta) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("%-30s = %04x (%d mv)\n",adc_inputs[i].name, raw,scaled);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; last[i]=raw;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:42:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190751#M3673</guid>
      <dc:creator>dereksnell</dc:creator>
      <dc:date>2020-10-29T09:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190752#M3674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Derek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the right way of adding LWADC to other BSPs?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have clone of bsp_twrk60f120m.&amp;nbsp; I created the folder lwadc under Peripheral IO Drivers and added the follwing files:&lt;/P&gt;&lt;P&gt;lwadc_k21.c&lt;/P&gt;&lt;P&gt;lwadc_kadc_prv.h&lt;/P&gt;&lt;P&gt;lwadc_kadc.c&lt;/P&gt;&lt;P&gt;lwadc_kadc.h&lt;/P&gt;&lt;P&gt;lwadc.h&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also added this line in user_config.h&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;#define&amp;nbsp;&amp;nbsp;&amp;nbsp; BSPCFG_ENABLE_LWADC&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I build the project, CW complains of many errors.&amp;nbsp; The first of which is:&lt;/P&gt;&lt;P&gt;C:/Freescale/CW MCU v10.3/MCU/ARM_Tools/Command_Line_Tools/mwccarm|Compiler|Error&lt;/P&gt;&lt;P&gt;(C:\Freescale\Freescale_MQX_4_0\mqx\source\io\lwadc\lwadc_kadc.c|48|27|16|1793|16)&lt;/P&gt;&lt;P&gt;=static void _lwadc_restart(LWADC_STRUCT_PTR lwadc_ptr) &lt;/P&gt;&lt;P&gt;&amp;gt;illegal function definition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could it be related to thi?&amp;nbsp; In section 22.3 of the MQXIOUG.pdf it says "The platform specific header should be included before lwadc.h."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which header file is specific to the K60?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;Joey&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 02:13:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190752#M3674</guid>
      <dc:creator>joey81</dc:creator>
      <dc:date>2013-02-19T02:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190753#M3675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello joey81,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suggest you to look for lwadc in another bsp to find out all places which you should change in your bsp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's take an example from TWRPXN20 bsp to highlight all lwadc related declarations/definitions, there's init_lwadc file where is definition of lwadc structure, create this structure according to your board.&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13612557984845534" jivemacro_uid="_13612557984845534"&gt;
&lt;P&gt;const LWADC_INIT_STRUCT lwadc0_init = { 0, LWADC_FORMAT_RIGHT_JUSTIFIED, BSP_PERI3_CLOCK, BSP_ADC_VREF_DEFAULT };&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;includes in bsp header file&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_13612557294259840 jive_macro_code" jivemacro_uid="_13612557294259840"&gt;
&lt;P&gt;#include &amp;lt;lwadc_mpxnxx.h&amp;gt;&lt;/P&gt;
&lt;P&gt;#include &amp;lt;lwadc_mpxn20.h&amp;gt;&lt;/P&gt;
&lt;P&gt;#include &amp;lt;lwadc.h&amp;gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;bsp_prv header file declares extern structure&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13612557293426706" jivemacro_uid="_13612557293426706"&gt;
&lt;P&gt;extern const LWADC_INIT_STRUCT lwadc0_init;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's conditionaly compiled code in init_bsp code file&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13612557293219777" jivemacro_uid="_13612557293219777"&gt;
&lt;P&gt;#if BSPCFG_ENABLE_LWADC&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;#if BSPCFG_ENABLE_LWADC0&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; _lwadc_init(&amp;amp;lwadc0_init);&amp;nbsp; &lt;/P&gt;
&lt;P&gt;#endif&lt;/P&gt;
&lt;P&gt;#endif&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Last file is the board header which should contain all macros which are used in the driver (check LWADC DRIVER CONFIGURATION). The next step is to customize lwadc driver ( create your own lwadc_k60 file because I believe there is more than just one ADC module).&lt;/P&gt;&lt;P&gt;&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>Thu, 29 Oct 2020 09:42:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190753#M3675</guid>
      <dc:creator>c0170</dc:creator>
      <dc:date>2020-10-29T09:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: A/D Driver Unable to Open Channel</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190754#M3676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joey,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know if you are still looking at this, but I was able to successfully implement lwadc for the TWRK20D72M MQX 4.0.1 bsp (&lt;A _jive_internal="true" href="https://community.nxp.com/thread/308825"&gt;https://community.freescale.com/thread/308825&lt;/A&gt;).&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a lot of work and I had to reload MQX twice because I trashed the bsp(s) but it is possible and lwadc works quite well.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe somebody at FSL can describe how to port in a driver like this easily.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;myke&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jun 2013 19:18:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/A-D-Driver-Unable-to-Open-Channel/m-p/190754#M3676</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2013-06-27T19:18:33Z</dc:date>
    </item>
  </channel>
</rss>

