<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78994/how-to-use-nrf5340-as-a-usb-microphone-device</link><description>I want to use nrf5340 as a USB Audio Microphone. 
 I am taking the help of zephyr/samples/subsys/usb/audio/headphones_microphone sample app, which contains USB Headphone + USB Microphone. 
 To disable USB Headphone, I am commenting hp_dev related code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 13 May 2024 13:14:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78994/how-to-use-nrf5340-as-a-usb-microphone-device" /><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/483061?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 13:14:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39da1aa7-aa9e-44c8-8c3a-ae542c81750b</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;tried to locate the code I set up originally, but I couldn&amp;#39;t find it unfortunately. It&amp;#39;s been many years and at least one PC upgrade since then.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I believe the essential step was to add the data_request_cb to the microphone device as I mentioned in my reply, and provide a data buffer here. This callback will occur over and over allowing you to keep the audio stream running.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/482164?ContentTypeID=1</link><pubDate>Tue, 07 May 2024 06:36:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2751a16-cbb5-44ae-be6d-10614c81acb8</guid><dc:creator>Sunil vignesh</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/ovrebekk"&gt;ovrebekk&lt;/a&gt; ,I want to replicate exactly what you did with a USB microphone to send PCM buffer and capture it in audacity. Could you share the source code to replicate?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/478700?ContentTypeID=1</link><pubDate>Mon, 15 Apr 2024 09:36:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3a2ee4c-4d67-4572-9e7c-176e1b38feef</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;It&amp;#39;s more than 3 years since Rashmi posted in this ticket. If you are having issues I would recommend opening a new ticket, and include a summary of what you have tried and the issues you are facing, and we can have a look at it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/477501?ContentTypeID=1</link><pubDate>Mon, 08 Apr 2024 09:37:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0a24e19-ad3f-4056-afc7-77db0c8a2718</guid><dc:creator>upasna maurya</dc:creator><description>&lt;p&gt;Hi RashmiV&lt;/p&gt;
&lt;p&gt;Actually I want to work on the&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="reference external" href="https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/subsys/usb/audio/headphones_microphone"&gt;samples/subsys/usb/audio/headphones_microphone&lt;/a&gt;&amp;nbsp;project. and need a help from you that which hardware you used for the usb microphone and usb headphone to interface with the nrf5340 dev kit?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/347873?ContentTypeID=1</link><pubDate>Sat, 15 Jan 2022 22:21:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18632286-9198-4d58-871a-c0dd34fa5d29</guid><dc:creator>Jeffrey Haynes</dc:creator><description>&lt;p&gt;Are you able to post your code?&amp;nbsp; This seems like a reasonable approach but so far I haven&amp;#39;t been able to get it to work without errors.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/327892?ContentTypeID=1</link><pubDate>Fri, 03 Sep 2021 07:07:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b98bc57-aa8f-4073-a612-d7a192fad016</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Did this problem occur once you changed from sending a sine wave to sending I2S data?&lt;/p&gt;
&lt;p&gt;Have you done some debugging on the nRF side to verify that the I2S data looks OK when you get it from the I2S driver?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/327715?ContentTypeID=1</link><pubDate>Thu, 02 Sep 2021 07:42:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62aa567d-3f92-408c-915d-e054eb26d89f</guid><dc:creator>RashmiV</dc:creator><description>&lt;p&gt;No, that is not the case. I have enabled only the microphone device in my code, I am not enabling the headphone device. My dts also has only the microphone. The dts is as follows:&lt;br /&gt;&amp;amp;usbd {&lt;br /&gt;mic_0 {&lt;br /&gt;label = &amp;quot;MICROPHONE&amp;quot;;&lt;br /&gt;compatible = &amp;quot;usb-audio-mic&amp;quot;;&lt;br /&gt;feature-mute;&lt;br /&gt;channel-l;&lt;br /&gt;channel-r;&lt;br /&gt;};&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;So on the host side, for output I only see one option: the standard system speaker. Whereas for input I see two options: standard mic input and zephyr mic, from which I select the zephyr mic to send audio from the nrf to the host.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/327705?ContentTypeID=1</link><pubDate>Thu, 02 Sep 2021 06:52:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ccd7d95-c7bc-40f0-80db-4a9363ea5fb9</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could it be that your host is trying to play back audio to your nRF device as well, over USB?&lt;/p&gt;
&lt;p&gt;Could you try to change the playback device on the host side to ensure that you play sound to the standard sound driver, and not the USB driver set up by the nRF device?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/327622?ContentTypeID=1</link><pubDate>Wed, 01 Sep 2021 12:50:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8e4c39b-32c7-4b6c-97c1-aba87ca71466</guid><dc:creator>RashmiV</dc:creator><description>&lt;p&gt;Thanks for your input. I was using another audio recorder for capturing the incoming audio. With your suggestion, I added data_request_cb and used it to send the audio buffer to the host. With this, I was successfully able tos send 192k static PCM buffers of 400hz and 600hz sine wave and record it at the host side. Now I would like to send dynamic audio values to the host. My input is coming from an I2S interface which I want to relay to the USB host. The I2S gives me 1920 bytes of data every 10ms, which I am memcopying into a buffer, and sending over USB inside data_request_cb. From wireshark, I can see that the data is being transmitted to the host successfully, but now again I am not able to hear it after recording on the host side. Any suggestions that I can try?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/327209?ContentTypeID=1</link><pubDate>Mon, 30 Aug 2021 12:16:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8eef68b7-84e2-4f73-a363-b2a52e977cb2</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How are you receiving the sound on the host side?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unless you have some program trying to get sound from the microphone device, you won&amp;#39;t be able to send anything from the nRF device.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In my case I am using the Audacity audio editing application in order to record audio, as this program makes it very easy to select the input source:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1630325651765v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I decided to test this myself based on your input, and realized that using the &lt;em&gt;data_written_cb&lt;/em&gt; callback was not the easiest way to use the microphone class.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Instead I configured the&amp;nbsp;&lt;em&gt;data_request_cb &lt;/em&gt;callback, which will be triggered every time the host opens the microphone port for input. Then I could prepare a packet for sending here and send it over the USB interface.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/327081?ContentTypeID=1</link><pubDate>Sun, 29 Aug 2021 17:29:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81fa3d6d-6480-4b80-a363-e38dc3d0568e</guid><dc:creator>RashmiV</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;t&lt;/p&gt;
&lt;p&gt;Thanks, I handled the buffers so that they don&amp;#39;t fill up, and also wrote the data_written_cb. Within this callback, I am sending 192 bytes of audio data by calling usb_audio_send() again so that data is sent continuously after each successfully data_written_cb call. I can now see the Zephyr USB audio sample listed in the Audio Input devices of the host device. But I can not hear any sound on my host device. I tried sending a 400Hz sine wave, 600Hz sine wave, and also a 1 sec sample of a song (192k sized buffer), but I cannot hear any of those on the host default speaker. I captured the incoming USB data on the host device using wireshark, and it looks like the buffer that I am sending is getting received at the host side. But I am also seeing this error on wireshark : &lt;br /&gt;USB isodesc 0 [Protocol error (-EPROTO)] (192 bytes)&lt;br /&gt; Status: Protocol error (-EPROTO) (-71)&lt;/p&gt;
&lt;p&gt;One USB packet as captured on wireshark is as follows:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;00 de e9 93 00 88 ff ff 43 00 88 78 02 00 2d 00 .&amp;THORN;&amp;eacute;...&amp;yuml;&amp;yuml;C..x..-.&lt;br /&gt;c6 be 2b 61 00 00 00 00 8d c3 01 00 00 00 00 00 &amp;AElig;&amp;frac34;+a.....&amp;Atilde;......&lt;br /&gt;c0 00 00 00 d0 00 00 00 00 00 00 00 01 00 00 00 &amp;Agrave;...&amp;ETH;...........&lt;br /&gt;01 00 00 00 82 01 00 00 04 02 00 00 01 00 00 00 ................&lt;br /&gt;b9 ff ff ff 00 00 00 00 c0 00 00 00 00 00 00 00 &amp;sup1;&amp;yuml;&amp;yuml;&amp;yuml;....&amp;Agrave;.......&lt;br /&gt;00 08 00 00 3c aa e3 59 b3 52 bf e7 36 fe aa 62 ....&amp;lt;&amp;ordf;&amp;atilde;Y&amp;sup3;R&amp;iquest;&amp;ccedil;6&amp;thorn;&amp;ordf;b&lt;br /&gt;29 be 72 55 fc 11 e4 55 ec 66 62 66 b4 0f 29 cc )&amp;frac34;rU&amp;uuml;.&amp;auml;U&amp;igrave;fbf&amp;acute;.)&amp;Igrave;&lt;br /&gt;e5 de ea a0 26 b9 8a 00 2b ff 61 43 06 d1 ed 00 &amp;aring;&amp;THORN;&amp;ecirc;&amp;nbsp;&amp;amp;&amp;sup1;..+&amp;yuml;aC.&amp;Ntilde;&amp;iacute;.&lt;br /&gt;00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................&lt;br /&gt;00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................&lt;br /&gt;00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................&lt;br /&gt;00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................&lt;br /&gt;00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................&lt;br /&gt;00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................&lt;br /&gt;00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................&lt;br /&gt;00 00 00 01 00 00 a8 04 2e 03 20 00 00 c0 00 04 ......&amp;uml;... ..&amp;Agrave;..&lt;br /&gt;2e 03 20 10 e2 07 8d b6 09 a5 f8 7b 56 8e f6 e0 .. .&amp;acirc;..&amp;para;.&amp;yen;&amp;oslash;{V.&amp;ouml;&amp;agrave;&lt;/p&gt;
&lt;p&gt;What could be wrong?&lt;br /&gt;Let me know if you want the entire wireshark capture, or want to look at the code. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to use nrf5340 as a USB Microphone device?</title><link>https://devzone.nordicsemi.com/thread/326938?ContentTypeID=1</link><pubDate>Fri, 27 Aug 2021 09:23:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86b4de4b-1fca-4c5a-abc1-3b796ef8ae13</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;You mean you run the code in a loop as fast as possible?&lt;/p&gt;
&lt;p&gt;Then you will eventually run out of net_buffers, or&amp;nbsp;fill up the USB buffers.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you checking the return codes from&amp;nbsp;&lt;span&gt;&lt;em&gt;net_buf_alloc(..)&lt;/em&gt; and&amp;nbsp;&lt;em&gt;usb_audio_send(..)&lt;/em&gt; to see if they return any errors?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I would recommend registering the&amp;nbsp;&lt;/span&gt;data_written_cb callback in the hp_ops setup, so that you get a callback whenever an audio packet is successfully sent over the USB interface. Then you can use this to schedule the next update.&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>