<?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>Kinetis MicrocontrollersのトピックRe: Sampling audio via UART (with PEx) with KL26Z64</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399966#M22166</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;P&gt;Hi, Mark. I'm using a FRDM-KL25Z board as a debugger (with USBDM). I know USBDM offers CDC support. How would I implement it using uTasker? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gustavo.&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Apr 2015 17:25:20 GMT</pubDate>
    <dc:creator>gustavsl</dc:creator>
    <dc:date>2015-04-13T17:25:20Z</dc:date>
    <item>
      <title>Sampling audio via UART (with PEx) with KL26Z64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399963#M22163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. I'm using a custom board with KL26Z64 and I'm trying to make a program that measures the ADC (to which a mic is connected) and sends the value via UART (serial) with a certain sample rate (in this case, 10kHz) indefinitely.&lt;/P&gt;&lt;P&gt;I want to capture audio to do some processing on a PC later.&lt;/P&gt;&lt;P&gt;I started a project with Processor Expert and added the ADC, Term (which uses AsynchroSerial) and TimerInt components. I set the timer interrupt period to 100us.&lt;/P&gt;&lt;P&gt;The baud rate is set to 38400 baud.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;My ADC total conversion time is set to 11.68us and I'm running 3 conversions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;My code to do this task is as follows (on the timer interrupt event):&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_1428889775820936" jivemacro_uid="_1428889775820936"&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG style="font-family: 'andale mono', times;"&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt; &lt;STRONG&gt;TI1_OnInterrupt&lt;/STRONG&gt;(&lt;SPAN class="s1"&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD1_Measure(TRUE);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD1_GetValue16(&amp;amp;leitura);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Term1_SendNum(leitura);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Term1_SendStr(&lt;SPAN class="s2"&gt;"\r\n"&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a result, I get the ADC values on my serial monitor. However, when I import these values to, say, MATLAB for processing, I see that the audio was not sampled at the correct rate.&lt;/P&gt;&lt;P&gt;What would be the most efficient way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gustavo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 01:54:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399963#M22163</guid>
      <dc:creator>gustavsl</dc:creator>
      <dc:date>2015-04-13T01:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sampling audio via UART (with PEx) with KL26Z64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399964#M22164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From customer description, the ADC sampling rate is 10KHz, and each sampling point will do three conversion.&lt;/P&gt;&lt;P&gt;When one sampling point ADC conversion done, it will transfer sampling point conversion result (three conversion results) to UART.&lt;/P&gt;&lt;P&gt;So, the three conversion result will make the sampling frequency modified, which is not 10KHz.&lt;/P&gt;&lt;P&gt;Customer just need to adjust the three ADC conversion results to one and send to UART port, which could get the 10KHz sampling rate.&lt;/P&gt;&lt;P&gt;Wish it helps.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 07:14:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399964#M22164</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2015-04-13T07:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sampling audio via UART (with PEx) with KL26Z64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399965#M22165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gustav&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you send a single sample point as ASCII you need to send 6 characters (eg. "0123\r\n").&lt;/P&gt;&lt;P&gt;At 38400 Baud this takes about (286us * 6) = 1.7ms&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This means that the highest sample rate that you can achieved at the moment is 581Hz for a single ADC channel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the PEx generated code will probably be blocking code so no further interrupts can be handled until the serial transission has completed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore you certainly need much faster data transfer that 38400 Baud ( &amp;gt;660kBaud for a single channel); USB-CDC would probably be more suitable, which can easily achieve 8 MBaud.&lt;/P&gt;&lt;P&gt;However I wouldn't send from the ADC interrupt routine but instead use DMA to a buffer and then send from the buffer (which can bridge short periods where transmission may be delayed).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Complete solutions for such tasks are included in the uTasker project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinetis: &lt;A href="http://www.utasker.com/kinetis.html" title="http://www.utasker.com/kinetis.html"&gt;µTasker Kinetis support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;KL26: &lt;A href="http://www.utasker.com/kinetis/FRDM-KL26Z.html" title="http://www.utasker.com/kinetis/FRDM-KL26Z.html"&gt;µTasker Kinetis FRDM-KL26Z support&lt;/A&gt; / &lt;A href="http://www.utasker.com/kinetis/TEENSY_LC.html" title="http://www.utasker.com/kinetis/TEENSY_LC.html"&gt;µTasker Kinetis Teensy LC support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;ADC/DAC: &lt;A href="http://www.utasker.com/docs/uTasker/uTaskerADC.pdf" title="http://www.utasker.com/docs/uTasker/uTaskerADC.pdf"&gt;http://www.utasker.com/docs/uTasker/uTaskerADC.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;USB User's Guide: &lt;A href="http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF" title="http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF"&gt;http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Composite USB: &lt;A href="http://www.utasker.com/kinetis/USB_Device.html" title="http://www.utasker.com/kinetis/USB_Device.html"&gt;µTasker USB Device Configuration&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For the complete "out-of-the-box" Kinetis experience and faster time to market&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 08:26:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399965#M22165</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2015-04-13T08:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Sampling audio via UART (with PEx) with KL26Z64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399966#M22166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;P&gt;Hi, Mark. I'm using a FRDM-KL25Z board as a debugger (with USBDM). I know USBDM offers CDC support. How would I implement it using uTasker? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gustavo.&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 17:25:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399966#M22166</guid>
      <dc:creator>gustavsl</dc:creator>
      <dc:date>2015-04-13T17:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sampling audio via UART (with PEx) with KL26Z64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399967#M22167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gustav&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The USBDM includes a USB-CDC to UART bridge to the KL25 and so the KL25 is communicating via UART. This means that the USBDM is not a design reference in this sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the uTasker project you would send a sample to the UART output by changing the code from your version (although preferably not located in the IRQ):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD1_Measure(TRUE);&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD1_GetValue16(&amp;amp;leitura);&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Term1_SendNum(leitura);&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Term1_SendStr(&lt;/STRONG&gt;&lt;SPAN class="string"&gt;&lt;STRONG&gt;"\r\n"); &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;uTasker code:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD1_Measure(TRUE);&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD1_GetValue16(&amp;amp;leitura);&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnDebugHex(leitura, (sizeof(leitura) | WITH_CR_LF)); // per default this is sent to the UART debug output&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;To send it to a USB-CDC output instead USB-CDC would be added to the project using the defines:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;STRONG&gt;#define USB_INTERFACE&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="string"&gt;#define USE_USB_CDC&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;STRONG&gt;#define USB_CDC_COUNT&amp;nbsp;&amp;nbsp; 1&lt;/STRONG&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; (can be 1 to 7 on the Kinetis)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;Then the code would redirect to a USB-CDC interface instead by doing:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="string"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DebugHandle = USBPortID_comms[0];&lt;/STRONG&gt; // where there can be up to 7 to choose from&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD1_Measure(TRUE);&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AD1_GetValue16(&amp;amp;leitura);&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnDebugHex(leitura, (sizeof(leitura) | WITH_CR_LF));&lt;/STRONG&gt; // this is now set to the defined USB-CDC connection&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So to use USB-CDC in the uTasker project you need to add one line of code to set the output to be used (after enabling the framework support with three defines).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;See also the FRDM-KL25Z binaries at &lt;A href="http://www.utasker.com/kinetis/FRDM-KL25Z.html" title="http://www.utasker.com/kinetis/FRDM-KL25Z.html"&gt;µTasker Kinetis FRDM-KL25Z support&lt;/A&gt; which includes a 3 way USB-CDC composite UART bridge configuration that you can try on your FRDM-KL25Z.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinetis: &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/kinetis.html" target="_blank"&gt;µTasker Kinetis support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;KL26: &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/kinetis/FRDM-KL26Z.html" target="_blank"&gt;µTasker Kinetis FRDM-KL26Z support&lt;/A&gt; / &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/kinetis/TEENSY_LC.html" target="_blank"&gt;µTasker Kinetis Teensy LC support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;ADC/DAC: &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/docs/uTasker/uTaskerADC.pdf" target="_blank"&gt;http://www.utasker.com/docs/uTasker/uTaskerADC.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;USB User's Guide: &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF" target="_blank"&gt;http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Composite USB: &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/kinetis/USB_Device.html" target="_blank"&gt;µTasker USB Device Configuration&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For the complete "out-of-the-box" Kinetis experience and faster time to market&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Apr 2015 18:07:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399967#M22167</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2015-04-13T18:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Sampling audio via UART (with PEx) with KL26Z64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399968#M22168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Mark. I'll try this approach (it'll be my first time using uTasker). It seems ideal.&lt;/P&gt;&lt;P&gt;May I get back to you in case of any issues (or in the uTasker community forum)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gustavo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 00:55:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Sampling-audio-via-UART-with-PEx-with-KL26Z64/m-p/399968#M22168</guid>
      <dc:creator>gustavsl</dc:creator>
      <dc:date>2015-04-14T00:55:39Z</dc:date>
    </item>
  </channel>
</rss>

