<?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>Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53751/problem-with-usb-cdc-data-transfer</link><description>I&amp;#39;m experiencing a strange issue with the USB CDC example when connecting the nRF52840 to Windows 10. This is with the 15.2 SDK. I&amp;#39;m using the usbd_ble_uart example on the BMD340 DK. When building the stock example and connecting the BMD-USB port to my</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 Nov 2019 09:34:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53751/problem-with-usb-cdc-data-transfer" /><item><title>RE: Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/thread/218759?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2019 09:34:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f89b486e-2a1d-4efb-ade4-a54fcdd47f19</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;I placed it just before entering the loop. The important part is to set it before you enumerate, usually in the init will be fine.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a quick LE to BE 32 unsigned macro, so that your baud is read out correct on the host side:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define LE_TO_BE32(x) \
        (x &amp;gt;&amp;gt;24 &amp;amp; 0xff) |   \
        ((x&amp;lt;&amp;lt;8)&amp;amp;0xff0000) | \
        ((x&amp;gt;&amp;gt;8)&amp;amp;0xff00) | \
        ((x&amp;lt;&amp;lt;24)&amp;amp;0xff000000)

    const uint32_t baud_rate = LE_TO_BE32 (115200);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can ofcourse set this to whatever baud you&amp;#39;d like (without it having an effect on the USB throughput), its really only meant as a &amp;quot;meta data&amp;quot; if you actually communicate with an external device using UART.&lt;/p&gt;
&lt;p&gt;Do you get the correct baud settings now?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/thread/218666?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2019 17:31:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be2fca99-6d51-4d01-ad35-21905f95dd40</guid><dc:creator>jemiaha</dc:creator><description>&lt;p&gt;Thanks!. I&amp;#39;m exploring that. It has an effect and I do see some strange values in the sniffer. Right now, in the USB setup there is the following code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;app_usbd_class_inst_t const * class_cdc_acm = app_usbd_cdc_acm_class_inst_get(&amp;amp;m_app_cdc_acm);
ret = app_usbd_class_append(class_cdc_acm);
APP_ERROR_CHECK(ret);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Where should the memcpy go in relation to that? (Before or after?)&lt;br /&gt;Thanks&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/thread/218501?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2019 10:25:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f9c74a2-f029-4fcd-baa8-781d51524674</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>[quote user="jemiaha"]With the usbd_ble_uart example, to remove possible sources of the problem, I&amp;#39;ve removed/disabled the soft device and re-compiled it with&amp;nbsp;ORIGIN = 0x0. The BT part is disabled but the USB CDC part is still testable.[/quote]
&lt;p&gt;&amp;nbsp;Why not test directly with usbd_cdc_acm? If you remove all the handling wrt. BLE in that sample, you&amp;#39;re ending essentially up with the same functionality as in that sample, just that you also need to handle the logic around the USBD events so that they do not go through the SoftDevice anymore.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="jemiaha"]So far, the only difference I can detect between a good connection and a bad connection is that with a good connection the virtual comm port connection parameters&amp;nbsp;are already setup. That why I was looking for a way to preset them from the nRF SDK side at compile time. So far as I can tell, there isn&amp;#39;t a way to do this. Do you know of a way?[/quote]
&lt;p&gt;There&amp;#39;s no function for setting this explicitly, but you can do this in main:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    const uint32_t baud_rate = 115200;
    app_usbd_cdc_line_coding_t line_coding = 
    {
      .dwDTERate = &amp;amp;baud_rate,
      .bCharFormat = APP_USBD_CDC_LINE_STOPBIT_1,
      .bParityType = APP_USBD_CDC_LINE_PARITY_NONE,
      .bDataBits = 8,
    };
    memcpy(&amp;amp;m_app_cdc_acm.specific.p_data-&amp;gt;ctx.line_coding, &amp;amp;line_coding, sizeof(app_usbd_cdc_line_coding_t));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am a bit unsure about the endianess on the dwDTERate member, you might have to swap the bytes if you see some weird values in that field.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/thread/217999?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2019 15:26:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66dddfad-9a49-4e62-b74e-31c8bcf1dce3</guid><dc:creator>jemiaha</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;H&amp;aring;kon,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; I&amp;#39;ve been doing all my testing on the PCA10056 DK while waiting for the customer&amp;#39;s custom board to be completed. I&amp;#39;m using the&amp;nbsp;usbd_ble_uart and peripheral/cli examples. The issue is observable with the&amp;nbsp;usbd_ble_uart example with no modifications by watching the DK LEDs. With the&amp;nbsp;&lt;span&gt;peripheral/cli example I made a small modification&amp;nbsp;that toggled a&amp;nbsp;DK LED every time a byte was received. With the usbd_ble_uart example, to remove possible sources of the problem, I&amp;#39;ve removed/disabled the soft device and re-compiled it with&amp;nbsp;ORIGIN = 0x0. The BT part is disabled but the USB CDC part is still testable. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The two examples setup the USB CDC UART differently&amp;nbsp;but both suffer from the same issue. We&amp;#39;re continuing to dig into the SW libraries used on the Windows10 side to see if there is some kind of negative&amp;nbsp;interaction between the serial&amp;nbsp;port libraries and the Virtual com-port setup.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So far, the only difference I can detect between a good connection and a bad connection is that with a good connection the virtual comm port connection parameters&amp;nbsp;are already setup. That why I was looking for a way to preset them from the nRF SDK side at compile time. So far as I can tell, there isn&amp;#39;t a way to do this. Do you know of a way?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/thread/217724?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2019 09:54:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a70091bd-58cf-4ee6-ae15-6dc0994471bb</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Are you testing on a custom board? if yes; is there any components on the D+/D- lines that might cause this?&lt;/p&gt;
&lt;p&gt;Are you able to reproduce this with a DK?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/thread/217403?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2019 20:51:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73b22c57-7e88-4287-aec6-0763b7498fe2</guid><dc:creator>jemiaha</dc:creator><description>&lt;p&gt;I&amp;#39;ve been able to look more closely at the log files from the sniffer software (Serial Port Monitor, Eltima). After comparing the logs from the terminal emulator and from a simple Python script I can see that the initial 0 values I for baud and data width&amp;nbsp;seem to be normal. From what I gather it&amp;#39;s normal for there to be multiple opens and closes of the port behind the scenes by the OS before it&amp;#39;s actually opened for tx/rx.&lt;/p&gt;
&lt;p&gt;The start of the issue is actually later in the log files. The nRF52840 gives no sign that a connection was made (APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN) though the driver thinks it as made a connection. When the port is finally opened for writing the first&amp;nbsp;call to IRP_MJ_WRITE registers as successfully when it actually wasn&amp;#39;t (No RX shown by the nRF52840, APP_USBD_CDC_ACM_USER_EVT_RX_DONE). The second&amp;nbsp;call to&amp;nbsp;&lt;span&gt;IRP_M&lt;/span&gt;&lt;span&gt;J&lt;/span&gt;&lt;span&gt;_WRITE&lt;/span&gt; times-out with STATUS_TIMEOUT. All following write attempts of &lt;span&gt;IRP_MJ_WRITE&amp;nbsp;&lt;/span&gt;also fail but with &lt;span&gt;STATUS_IO_TIMEOUT.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m still doing compares between good and bad logs to find more clues.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/thread/217391?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2019 17:04:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:320c23be-41a3-45e2-b73b-42a2b2205e13</guid><dc:creator>jemiaha</dc:creator><description>&lt;p&gt;I should also add that I&amp;#39;ve used the customer&amp;#39;s application to connect to other USB&amp;nbsp;serial devices without this problem. I&amp;#39;ve honestly never encountered a situation like this where a virtual com port could be opened but not transfer any data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/thread/217377?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2019 15:40:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:569dfe5b-5eb7-4bf3-9c58-e85b68e8e4d0</guid><dc:creator>jemiaha</dc:creator><description>&lt;p&gt;Thanks for the response. The issue is that if I program the usbd_ble_uart example into the nRF52840, cycle its power, and open its virtual com-port with a terminal emulator first it works fine. When repeat those steps and try to open the port with my customer&amp;#39;s application first the port is unable to send/receive data. If I open the port with&amp;nbsp;a terminal emulator, close it, then open it with my customer&amp;#39;s application, the port&amp;nbsp;is able to send/receive data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the screen shots I posted,&amp;nbsp;you can see that the terminal emulator is heavy handed and writes the settings it wants as soon as it opens the port. My customer&amp;#39;s application tries to read the port settings first. The values it gets are strange and it fails to be able to send/receive data. Once the terminal emulator has opened the port the values for baud and data width are normal and my customer&amp;#39;s application can send/receive data. The customer&amp;#39;s application is already released and cannot be updated. They&amp;#39;re updating their hardware to use the&amp;nbsp;&lt;span&gt;nRF52840.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Virtual com-ports are usually very forgiving (unlike the old days of microcontroller USARTs right). This issue is strange in that I&amp;#39;ve never seen a virtual com-port have a bad &amp;quot;initial state&amp;quot; like this. I&amp;#39;m assuming there is some initial configuration on the&amp;nbsp;nRF52840 side that&amp;#39;s incorrect and it&amp;#39;s getting modified by the terminal emulator connection that corrects it. Any ideas you have on what I could look for would be greatly appreciated.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problem with USB CDC Data Transfer</title><link>https://devzone.nordicsemi.com/thread/217353?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2019 14:14:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f39d57d-270d-4df3-ad00-374337f72779</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Virtual com-ports does not really care about the settings, as everything goes over to USB anyway on the transport side. You can open up the port with 300 baud, and send MBits/s given that the device handles it. What is the issue that you are observing? Is the data missing or corrupted?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>