<?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>USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once</link><description>Our application stores sensor data in flash and sends the data on request via USB. But if the device is connected to Bluetooth once then it is having issues in USB data transfer. Device receives 21 bytes in place of 20 bytes. Receiving same packet twice</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 18 Nov 2020 09:58:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once" /><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/280557?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 09:58:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52aa5644-2234-44c1-bb98-5a593a7809c8</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="viznu3391"]On USB power detect event, we call sd_ble_gap_disconnect and&amp;nbsp;sd_ble_gap_adv_stop.[/quote]
&lt;p&gt;Thank you for clarifying.&lt;br /&gt;So, you connect your device to your phone through a cabled USB connection, and upon detecting this connection you disconnect any BLE connection and stop advertising.&lt;br /&gt;Then, you begin a transfer of sensor data over the USB, from the device to the phone.&lt;br /&gt;In this transfer ( which is entirely independent of BLE communications ) the issue appears, in which a CR character is added to the end of the transfer, when your phone is sending data to the device - but not the other way around. I.e the phone sends 20 bytes, but 21 is received by the device ( added CR character ), but when the device sends 20 bytes to the phone, only 20 bytes are received.&lt;br /&gt;Have I got this correctly?&lt;/p&gt;
[quote user="viznu3391"]I am sorry[/quote]
&lt;p&gt;No worries, I am just trying to make sure that I have understood the issue you are facing correctly :)&amp;nbsp;&lt;/p&gt;
[quote user="viznu3391"]I meant, the packets send by our application, not the empty packets.&amp;nbsp;[/quote]
&lt;p&gt;In this case,&amp;nbsp;&lt;em&gt;application&lt;/em&gt; here refers to your smartphone application that is sending data to your device over USB. Correct?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/280555?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 09:47:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfc93ec4-3855-47b2-b7df-8541907d601b</guid><dc:creator>Vishnu Pradeep</dc:creator><description>[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/280550#280550"]We disconnect the Bluetooth and stop advertising too when USB is connected.&amp;nbsp;[/quote]
&lt;p&gt;On USB power detect event, we call sd_ble_gap_disconnect and&amp;nbsp;sd_ble_gap_adv_stop.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/280550#280550"]Are you saying that the issue ( added CR character at the end of a transmission ) appears regardless of BLE connection status?[/quote]
&lt;p&gt;I am sorry I meant, the packets send by our application, not the empty packets.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/280550?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 09:41:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3648734-1e44-4edb-9a8f-5467ca553a22</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Vishnu,&lt;/p&gt;
[quote user="viznu3391"]It is not resettin&lt;span&gt;g. We disconnect the Bluetooth and stop advertising too when USB is connected.&amp;nbsp;&lt;/span&gt;[/quote][quote user="viznu3391"]Will try to do this. In fact the issue is happening without any Bluetooth packet exchange. I just connected the device to our app or nrf uart app and disconnected.[/quote]
&lt;p&gt;I am sorry, but I am not sure I understand what you mean by this. Are you saying that the issue ( added CR character at the end of a transmission ) appears regardless of BLE connection status?&lt;br /&gt;If so, I do not understand the part in which you say it happens without Bluetooth packet exchange, while also saying you are connected to the device through an app or nRF UART app?&lt;br /&gt;Please bear in mind that empty packets are constantly being exchanged in a connection where no communication is happening on the application layer.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/280542?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 09:14:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea9979c2-44b5-4856-bb60-5e789829dddc</guid><dc:creator>Vishnu Pradeep</dc:creator><description>[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/280517#280517"]Could you make sure that the device is not in fact resetting, when you connect the USB cable?[/quote]
&lt;p&gt;It is not resettin&lt;span&gt;g. We disconnect the Bluetooth and stop advertising too when USB is connected.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/280517#280517"]Are you familiar with the &lt;a href="https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Sniffer-for-Bluetooth-LE"&gt;nRF Sniffer tool&lt;/a&gt;? It would be very helpful if you could provide a trace of the BLE communication when this happens, along with a log file of the USB traffic.[/quote]
&lt;p&gt;Will try to do this. In fact the issue is happening without any Bluetooth packet exchange. I just connected the device to our app or nrf uart app and disconnected.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Vishnu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/280517?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 07:58:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d16e058-d9ff-4d1a-a284-ec7ec666c86d</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;span&gt;Vishnu Pradeep,&lt;br /&gt;&lt;br /&gt;Sorry for my late reply.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
[quote user="viznu3391"]Sorry I am using SDK 15.2. I cannot find this in sdk_config file.[/quote][quote user="viznu3391"]Well, NO. Actually 21 bytes are seen in the receive buffer. but android is sending only 20 bytes. That is the issue.[/quote]
&lt;p&gt;Thank you for clarifying.&lt;/p&gt;
[quote user="viznu3391"]As soon as the USB cable is plugged in, we are disconnecting Bluetooth for some reasons.[/quote]
&lt;p&gt;Could you make sure that the device is not in fact resetting, when you connect the USB cable?&lt;br /&gt;Depending on how you have configured your POWER sources, this might be the case.&lt;/p&gt;
[quote user="viznu3391"]After a 3 to 4 USB packets are exchanged without any issues, device is receiving a packet twice, which was supposed to receive only once.[/quote][quote user="viznu3391"]After that the communication simply stops. device tries to send data, but android is not getting anything, and feels like some error in packet send from device to android app.&amp;nbsp;[/quote]
&lt;p&gt;This sounds very strange indeed. Are you familiar with the &lt;a href="https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Sniffer-for-Bluetooth-LE"&gt;nRF Sniffer tool&lt;/a&gt;? It would be very helpful if you could provide a trace of the BLE communication when this happens, along with a log file of the USB traffic.&lt;/p&gt;
[quote user="viznu3391"]But if we connect bluetooth at any point of time after the power up, the issue arises.&amp;nbsp;[/quote]
&lt;p&gt;This would also be great to see happen in a sniffer trace + usb communication log.&amp;nbsp;&lt;/p&gt;
[quote user="viznu3391"]Can I remove nrf_drv_clock_lfclk_request[/quote]
&lt;p&gt;My mistake there, it seems I misread the request, instead thinking you were requesting the HF clock. The LF clock should have nothing to do with it.&lt;/p&gt;
&lt;p&gt;Looking forward to resolving this issue together!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/279796?ContentTypeID=1</link><pubDate>Thu, 12 Nov 2020 16:01:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84c1ac1f-0824-4086-adbd-a6132a87152c</guid><dc:creator>Vishnu Pradeep</dc:creator><description>[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/279778#279778"]Which function are you using to output this message? Could you show me the code snippets in which it is outputted.[/quote]
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void cdc_acm_user_ev_handler(app_usbd_class_inst_t const *p_inst,
    app_usbd_cdc_acm_user_event_t event) {
  app_usbd_cdc_acm_t const *p_cdc_acm = app_usbd_cdc_acm_class_get(p_inst);

  switch (event) {
  case APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN: {
    /*Set up the first transfer*/
    ret_code_t ret = app_usbd_cdc_acm_read(&amp;amp;m_app_cdc_acm,
        m_cdc_data_array,
        1);
    UNUSED_VARIABLE(ret);
    msg(&amp;quot;CDC ACM port opened&amp;quot;);
    break;
  }

  case APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE:
    msg(&amp;quot;CDC ACM port closed&amp;quot;);
    break;

  case APP_USBD_CDC_ACM_USER_EVT_TX_DONE:
    break;

  case APP_USBD_CDC_ACM_USER_EVT_RX_DONE: {
    ret_code_t ret;
    static uint8_t index = 0;
    index++;

    do {
      if ((m_cdc_data_array[index - 1] == &amp;#39;\n&amp;#39;) ||
          (m_cdc_data_array[index - 1] == &amp;#39;\r&amp;#39;) ||
          (index &amp;gt;= (m_ble_nus_max_data_len))) {
        if (index &amp;gt; 1) {
          msg(&amp;quot;USB data received %dbytes&amp;quot;, index);
          msg_hexdump(m_cdc_data_array, index);
          memcpy(usb_receive_buffer, m_cdc_data_array, index);
          usb_data_received = true;
        }
        index = 0;
        }
      
      /* Fetch data until internal buffer is empty */
      ret = app_usbd_cdc_acm_read(&amp;amp;m_app_cdc_acm,
          &amp;amp;m_cdc_data_array[index],
          1);
      if (ret == NRF_SUCCESS) {
        index++;
      }
    } while (ret == NRF_SUCCESS);

    break;
  }
  default:
    break;
  }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/279778#279778"]Could you check for me if you have defined&amp;nbsp;&lt;em&gt;NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED&lt;/em&gt; 1 in your sdk_config file?[/quote]
&lt;p&gt;Sorry I am using SDK 15.2. I cannot find this in sdk_config file.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/279778#279778"]Is the appended CR character what you are referring to when you say&amp;nbsp;&lt;em&gt;unexpected behaviors&lt;/em&gt;, or are you observing other unexpected behavior as well?[/quote]
&lt;p&gt;Well, NO. Actually 21 bytes are seen in the receive buffer. but android is sending only 20 bytes. That is the issue.&lt;/p&gt;
&lt;p&gt;My application is, storing the sensor data to a NAND flash and sending this data to android app via USB on request. The data size will be around 200MB-512 MB.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We are doing some packet exchange between android phone and our nRF peripheral before sending the actual data. We are seeing some unexpected packet exchange between the device if we&amp;#39;ve connected the device via Bluetooth after power up. As soon as the USB cable is plugged in, we are disconnecting Bluetooth for some reasons. After a 3 to 4 USB packets are exchanged without any issues, device is receiving a packet twice, which was supposed to receive only once. After that the communication simply stops. device tries to send data, but android is not getting anything, and feels like some error in packet send from device to android app.&amp;nbsp;&lt;br /&gt;Thus we&amp;#39;ve debugged and found that if we do not connect to our device using bluetooth after power up, the USB data transfer works smoothly. We are receiving only 20 bytes when android sends 20 bytes of request.&lt;br /&gt;But if we connect bluetooth at any point of time after the power up, the issue arises.&amp;nbsp;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/279778#279778"]It sounds strange that this only happens when connected to BLE, or if you have not power cycled the device. Perhaps this is related to your call to&amp;nbsp;nrf_drv_clock_lfclk_request, which is superseded when the SoftDevice is enabled.[/quote]
&lt;p&gt;Can I remove nrf_drv_clock_lfclk_request for our application? it is not called in usbd_ble_app_uart example code. but we are using RTC module in addition to example code.?&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/279778#279778"]Could you attempt to send the same test string with and without enabling the SoftDevice?[/quote]
&lt;p&gt;That will work. Because we are not connecting bluetooth, It works well if the device was not connected to bluetooth.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; best regards,&lt;/p&gt;
&lt;p&gt;Vishnu Pradeep&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/279778?ContentTypeID=1</link><pubDate>Thu, 12 Nov 2020 15:10:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54b75cc0-9c42-47c7-8d07-43b15f44fad8</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="viznu3391"]yes, I&amp;#39;ve added DEBUG. Not seeing any error message generated as such in debug log.[/quote]
&lt;p&gt;Thank you for&amp;nbsp;verifying this.&lt;/p&gt;
[quote user="viznu3391"]I was sending 20 bytes. BRK0000000000000000Z. But received 21 bytes with 0x0D at the end.[/quote]
&lt;p&gt;It seems a &lt;span&gt;Carriage Return character&amp;nbsp;&lt;/span&gt;is appended to the end of your message.&amp;nbsp;&lt;br /&gt;Which function are you using to output this message? Could you show me the code snippets in which it is outputted.&lt;br /&gt;&lt;br /&gt;Could you check for me if you have defined&amp;nbsp;&lt;em&gt;NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED&lt;/em&gt; 1 in your sdk_config file?&lt;br /&gt;This will automatically append CR for each Line Feed character.&amp;nbsp;&lt;/p&gt;
[quote user="viznu3391"]This is not happening if we are sending data via USB after power cycle and not connecting to Bluetooth. If the device gets connected to Bluetooth once after power on, USB data transfer is having some unexpected behaviors. If we don&amp;#39;t connect to Bluetooth and start USB data transfer after power up, it works fine.[/quote]
&lt;p&gt;Is the appended CR character what you are referring to when you say&amp;nbsp;&lt;em&gt;unexpected behaviors&lt;/em&gt;, or are you observing other unexpected behavior as well?&lt;br /&gt;It sounds strange that this only happens when connected to BLE, or if you have not power cycled the device. Perhaps this is related to your call to&amp;nbsp;nrf_drv_clock_lfclk_request, which is superseded when the SoftDevice is enabled.&lt;br /&gt;Could you attempt to send the same test string with and without enabling the SoftDevice?&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/279557?ContentTypeID=1</link><pubDate>Wed, 11 Nov 2020 15:50:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ac85705-1487-4b27-8b49-477fe1dc5725</guid><dc:creator>Vishnu Pradeep</dc:creator><description>[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/279518#279518"]Please confirm whether you have done this, and what you are seeing.&lt;br /&gt;[/quote]
&lt;p&gt;yes, I&amp;#39;ve added DEBUG. Not seeing any error message generated as such in debug log.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/279518#279518"]Is there any error message generated when the unexpected byte is sent?[/quote]
&lt;p&gt;No.&amp;nbsp;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/68126/usbd-issue-after-bluetooth-is-connected-once/279518#279518"]Could you tell me specifically which data is being sent here? What is the contents of the unexpected byte?&amp;nbsp;&lt;br /&gt;[/quote]
&lt;p&gt;I was sending 20 bytes. BRK0000000000000000Z. But received 21 bytes with 0x0D at the end. This is not happening if we are sending data via USB after power cycle and not connecting to Bluetooth. If the device gets connected to Bluetooth once after power on, USB data transfer is having some unexpected behaviors. If we don&amp;#39;t connect to Bluetooth and start USB data transfer after power up, it works fine.&lt;/p&gt;
&lt;p&gt;Actually we are sending data to android phone over OTG. Whenever the device is connected to any nRF uart app even on a different phone, this issue happens.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/279518?ContentTypeID=1</link><pubDate>Wed, 11 Nov 2020 14:20:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78221004-efe2-46ef-b1eb-384b128e1a10</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Vishnu,&lt;/p&gt;
[quote user="viznu3391"]This is my initialization sequence[/quote]
&lt;p&gt;This does not tell me much, unfortunately. I can only say that your app_usbd initialization looks all right to me.&lt;/p&gt;
[quote user="Karl Ylvisaker"]Is there any error messages being generated / outputted to your logger module?&lt;br /&gt;Please make sure that DEBUG is defined in your preprocessor defines, as shown in the included image.[/quote]
&lt;p&gt;Please confirm whether you have done this, and what you are seeing.&lt;br /&gt;What does the logger output when you establish the first connection? Is there any error message generated when the unexpected byte is sent?&lt;/p&gt;
[quote user="viznu3391"]Edit: Yes it is behaving the same with example code. Power on the device -&amp;gt; connect Bluetooth -&amp;gt; disconnect -&amp;gt; send data via USB, 21 bytes.&lt;br /&gt;If I power cycle and send data without connecting the Bluetooth, receives 20 bytes[/quote]
&lt;p&gt;Could you tell me specifically which data is being sent here? What is the contents of the unexpected byte?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/279117?ContentTypeID=1</link><pubDate>Tue, 10 Nov 2020 03:52:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c756baa7-5c57-4769-9584-7951cd950434</guid><dc:creator>Vishnu Pradeep</dc:creator><description>&lt;p&gt;This is my initialization sequence&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    timers_init();
    ret_code_t err_code = nrf_drv_clock_init();                        //Initialize the clock source specified in the nrf_drv_config.h file, i.e. the CLOCK_CONFIG_LF_SRC constant
    APP_ERROR_CHECK(err_code);
    nrf_drv_clock_lfclk_request(NULL);
   //Initialize RTC instance
   nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
   config.prescaler = 4095;
   err_code = nrf_drv_rtc_init(&amp;amp;rtc, &amp;amp;config, rtc_handler);
   APP_ERROR_CHECK(err_code);

   err_code = nrf_drv_rtc_cc_set(&amp;amp;rtc, 0, RTC_CC_VALUE, true); //Set RTC compare value to trigger interrupt. Configure the interrupt frequency by adjust RTC_CC_VALUE and RTC_FREQUENCY constant in top of main.c
   APP_ERROR_CHECK(err_code);

   //Power on RTC instance
   nrf_drv_rtc_enable(&amp;amp;rtc);
/* Register first to receive an event when initialization is complete. */
    (void) fds_register(fds_evt_handler);

    msg(&amp;quot;Initializing fds...&amp;quot;);

    ret_code_t rc = fds_init();
    APP_ERROR_CHECK(rc);

    /* Wait for fds to initialize. */
    wait_for_fds_ready();
    get_fds_stat();
     static const app_usbd_config_t usbd_config = {
      .ev_state_proc = usbd_user_ev_handler};

  app_usbd_serial_num_generate();
  ret = app_usbd_init(&amp;amp;usbd_config);
  APP_ERROR_CHECK(ret);

  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);
  ret = app_usbd_power_events_enable();
  APP_ERROR_CHECK(ret);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Edit: Yes it is behaving the same with example code. Power on the device -&amp;gt; connect Bluetooth -&amp;gt; disconnect -&amp;gt; send data via USB, 21 bytes.&lt;br /&gt;If I power cycle and send data without connecting the Bluetooth, receives 20 bytes&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USBD issue after bluetooth is connected once</title><link>https://devzone.nordicsemi.com/thread/279022?ContentTypeID=1</link><pubDate>Mon, 09 Nov 2020 13:45:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:394489c4-ed60-4511-bcf1-2adc23194132</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Vishnu,&lt;/p&gt;
[quote user=""]We wrote application over usbd_ble_uart_pca10056_s140 example.&amp;nbsp;[/quote][quote user=""]But if the device is connected to Bluetooth once then it is having issues in USB data transfer.[/quote]
&lt;p&gt;Please elaborate on which modifications you have done to the example. Did you test an unmodified version of the example as detailed in the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/usbd_ble_uart_example.html"&gt;USBD BLE UART example documentation section Setup and Testing&lt;/a&gt;? Did the unmodified example behaves as detailed in the documentation?&lt;br /&gt;&lt;br /&gt;The example demonstrates how the device can receive information through the UART service, and relay it to the usbd cdc acm module.&lt;/p&gt;
[quote user=""]Device receives 21 bytes in place of 20 bytes.[/quote]
&lt;p&gt;Could you verify for me that you are not in fact queueing 21 bytes for sending, such as if you are sending a \0 terminated c-string?&lt;br /&gt;&lt;br /&gt;Is there any error messages being generated / outputted to your logger module?&lt;br /&gt;Please make sure that DEBUG is defined in your preprocessor defines, as shown in the included image.&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7230.enabling_5F00_debug_5F00_SES.PNG" /&gt;&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>