<?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: Cannot re-open the ADC-driver in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Cannot-re-open-the-ADC-driver/m-p/174340#M2156</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Soli,&lt;/P&gt;&lt;P&gt;There was a bug in the MQX3.8 ADC for the fopen/fclose that has been fixed for our MQX3.8.1 release at end of month.&lt;/P&gt;&lt;P&gt;The release notes will have following:&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bug in case Kinetis ADC fopen/fclose was called multiple times fixed in PDB initialization.&lt;/P&gt;&lt;P&gt;Sorry for the hassle.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jun 2012 22:50:26 GMT</pubDate>
    <dc:creator>DavidS</dc:creator>
    <dc:date>2012-06-22T22:50:26Z</dc:date>
    <item>
      <title>Cannot re-open the ADC-driver</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Cannot-re-open-the-ADC-driver/m-p/174339#M2155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With the code below I open the adc, start reading adc and after than I close the adc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the first and the second call of my adc calls I get the correct measured values. But on third time I cannot open the adc driver.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Than the function “_adc_open” in kernel-file adc.c return me the value “ADC_ERROR_OPENED” (cannot open more than one instance of ADC driver).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have an idea what is going wrong here? Do I have a mistake by closing the driver?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for replay.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;const ADC_INIT_CHANNEL_STRUCT adc_channel_param ={    ADC0_SOURCE_AD0, /* physical ADC channel */    ADC_CHANNEL_START_TRIGGERED,    1,              /* number of samples in one run sequence */    0,              /* time offset from trigger point in us */    300000,         /* period in us (= 0.3 sec) */    0x10000,        /* scale range of result (not used now) */    1,              /* circular buffer size (sample count) */    ADC_PDB_TRIGGER,/* logical trigger ID that starts this ADC channel */};uint32_t adc_get_raw(void){    ADC_RESULT_STRUCT adc_data;    MQX_FILE_PTR adc_fp = NULL;    MQX_FILE_PTR channel_input_fp = NULL;    //!___open__________________________________________________________________    printf("Opening %s ...", MY_ADC);    adc_fp = fopen(MY_ADC, (const char*)&amp;amp;adc_init_sruct);    if(adc_fp != NULL)        printf("done\n");    else    {        printf("failed\n");        return 0;    }    printf("Opening channel ...");    channel_input_fp= fopen(MY_ADC "channel",(const char*)&amp;amp;adc_channel_param);    if(channel_input_fp != NULL)        printf("done\n");    else    {        printf("failed\n");        return 0;    }    _time_delay(500);    //!___start_measurement_____________________________________________________    ioctl(adc_fp, ADC_IOCTL_FIRE_TRIGGER, (pointer) MY_TRIGGER);    //!___measure_______________________________________________________________ if (read(channel_input_fp, &amp;amp;adc_data, sizeof(adc_data) )) {  printf("ADC: %4d \n", adc_data.result); }    if (IO_OK == ioctl (channel_input_fp, ADC_IOCTL_STOP_CHANNELS, NULL))    {        printf("stopped\n");    }    else    {        printf("failed\n");    }    //!___close_________________________________________________________________  //! close all ADC channels    printf("Close ADC channel...");    if ( fclose(channel_input_fp) == MQX_OK )        printf("ok\n");    printf("Close ADC driver...");    if ( fclose(adc_fp) == MQX_OK )        printf("ok\n");    else if ( fclose(adc_fp) == ADC_ERROR_NONEMPTY )     printf("--&amp;gt; ADC_ERROR_NONEMPTY --&amp;gt; failed\n");    else        printf("failed\n");    return adc_data.result;}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the debug output:&lt;/P&gt;&lt;P&gt;Opening adc0: ...done&lt;BR /&gt;Opening channel ...done&lt;BR /&gt;ADC: 2049&lt;BR /&gt;stopped&lt;BR /&gt;Close ADC channel...ok&lt;BR /&gt;Close ADC driver...ok&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Opening adc0: ...done&lt;BR /&gt;Opening channel ...done&lt;BR /&gt;ADC: 2034&lt;BR /&gt;stopped&lt;BR /&gt;Close ADC channel...ok&lt;BR /&gt;Close ADC driver...ok&lt;BR /&gt;&lt;BR /&gt;Opening adc0: ...done&lt;BR /&gt;Opening channel ...failed&lt;BR /&gt;&lt;BR /&gt;Opening adc0: ...failed&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:23:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Cannot-re-open-the-ADC-driver/m-p/174339#M2155</guid>
      <dc:creator>soli</dc:creator>
      <dc:date>2020-10-29T09:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot re-open the ADC-driver</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Cannot-re-open-the-ADC-driver/m-p/174340#M2156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Soli,&lt;/P&gt;&lt;P&gt;There was a bug in the MQX3.8 ADC for the fopen/fclose that has been fixed for our MQX3.8.1 release at end of month.&lt;/P&gt;&lt;P&gt;The release notes will have following:&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bug in case Kinetis ADC fopen/fclose was called multiple times fixed in PDB initialization.&lt;/P&gt;&lt;P&gt;Sorry for the hassle.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 22:50:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Cannot-re-open-the-ADC-driver/m-p/174340#M2156</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2012-06-22T22:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot re-open the ADC-driver</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Cannot-re-open-the-ADC-driver/m-p/174341#M2157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, thank you for response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 20:50:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Cannot-re-open-the-ADC-driver/m-p/174341#M2157</guid>
      <dc:creator>soli</dc:creator>
      <dc:date>2012-06-26T20:50:43Z</dc:date>
    </item>
  </channel>
</rss>

