This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB speed issue on nRF52840

Hi,

I'm using a BMD-340 module evaluation kit (Rigado) I modified usbd example and I can transfer data in between host and device. But I have issues with usb speed and I need more help to debug this issue.

The host side is using libusb-1.0, sending 16 X 64  = 1K bytes bulk data from ENDPOINTOUT1  using libusb_bulk_transfer function and after the device receiving 1 KByte data it's sending back the data to the host on ENDPOINTIN1. Data is transferred correctly but the time spent to do just 1 KByte transfer is very long and varying a lot. I measured varying rates from 2 - 100 KBytes/second. I tried various libusb drivers (winUSB, libusb-win32 and libusbK) to see any variation with data rate but didn't see any difference.

I'm  attaching the main.c for convenience.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* Copyright (c) 2016 - 2018, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I'm measuring the time spent to send and receive data on the usb device toggling LED's and measuring those using a logic analyzer.  

Using LED_SEND to measure time spent on ENDPOINTIN1 and using LED_RECEIVE to measure time on ENDPOINTOUT1. 

My understanding from the nRF52840_PS_v1.0.pdf,  usb has to run with the high frequency clock (which is 64 MHz ?) However even I don't run clock_init function (I comment out clock_init function (line#1052) I don't see any differences with the speed. It varies but it is very slow compared to expected bulk transfer rates.  At this point I don't know how to debug this speed issue further. I'm attaching two captures showing the SEND and RECEIVE times with and without hflck enabled. Can you please help with this?

Thank you and Best Regards,

Asli