soledad
NOTE: I AM USING A WINDOWS COMPUTER WITH AN INTEL I7 PROCESSOR
USB CONNECTIVITY AND DATA TRANSFER ISSUES
These are the approaches I have followed to get the USB connection this far:
- I tried connecting the micro USB of the LPC to one of the COM ports of the computer. I ran the simple USB program which have been given in the examples in the debugger mode, and tried to connect with the MCU, with the host program running (written on python).
- I tried to upload the MCU program on flash memory and further, connected just the evaluation board and then, ran the host program.
On both cases, I find the program on the MCU side getting stuck in the stage where it tries to check if the connection has been enabled. I am also sending you the copy of the codes I am using on both the MCU side as well as the host side.
PS: I have also tried running the program on the host side using other programming languages such as C and C# initially using the libusb and libusbdotnet libraries, both when run, give me the same error on the MCU side as I have already mentioned in the other messages we’ve conversed about – gets stuck on the checking for connection loop.
PROGRAM ON MCU and HOST SIDE:
MCU SIDE PROGRAM
#include "board.h"
#include <stdio.h>
#include <string.h>
#include "libusbdev.h"
/* The size of the packet buffer. */
#define PACKET_BUFFER_SIZE 4096
/* Application defined LUSB interrupt status */
#define LUSB_DATA_PENDING _BIT(0)
/* Packet buffer for processing */
static uint8_t g_rxBuff[PACKET_BUFFER_SIZE];
int main(void)
{
/* Initialize board and chip */
SystemCoreClockUpdate();
Board_Init();
/* Init USB subsystem and LibUSBDevice */
libusbdev_init(USB_STACK_MEM_BASE, USB_STACK_MEM_SIZE);
while (1) {
/* wait until host is connected */
while (libusbdev_Connected() == 0) {
/* Sleep until next IRQ happens */
__WFI(); à Gets stuck in this loop, libusbdev_Connected() always is 0.
}
while (libusbdev_Connected()) {
if (libusbdev_QueueReadDone() != -1) {
/* Dummy process read data ......*/
/* requeue read request */
libusbdev_QueueReadReq(g_rxBuff, PACKET_BUFFER_SIZE);
}
if (libusbdev_QueueSendDone() == 0) {
/* Queue send request */
libusbdev_QueueSendReq(g_rxBuff, PACKET_BUFFER_SIZE);
}
}
}
}
PROGRAM ON HOST SIDE:
Since I am using python, the program is quite easy to understand. Here, dev is the device that’s found using the “find” function of the usb.core - library.
dev1 = usb.core.find(idVendor = 0x1fc9, idProduct = 0x0090)
>>> print(dev1)
OUTPUT:
DEVICE ID 1fc9:0090 on Bus 001 Address 027 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x200 USB 2.0
bDeviceClass : 0xef Miscellaneous
bDeviceSubClass : 0x2
bDeviceProtocol : 0x1
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x1fc9
idProduct : 0x0090
bcdDevice : 0x100 Device 1.0
iManufacturer : 0x1 NXP Semiconductors
iProduct : 0x2 LPC-LINK2 DATA PORT
iSerialNumber : 0x3 I3FWNUOV
bNumConfigurations : 0x1
CONFIGURATION 1: 500 mA ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0xab (171 bytes)
bNumInterfaces : 0x5
bConfigurationValue : 0x1
iConfiguration : 0x0
bmAttributes : 0x80 Bus Powered
bMaxPower : 0xfa (500 mA)
INTERFACE 0: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x4 Error Accessing String
ENDPOINT 0x81: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
ENDPOINT 0x1: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x1 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
INTERFACE 4: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x4
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x7 Error Accessing String
ENDPOINT 0x84: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x84 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x1
ENDPOINT 0x4: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x4 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x1
INTERFACE 1: CDC Communication =========================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x1
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x2 CDC Communication
bInterfaceSubClass : 0x2
bInterfaceProtocol : 0x0
iInterface : 0x5 Error Accessing String
ENDPOINT 0x83: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x83 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x10 (16 bytes)
bInterval : 0x4
INTERFACE 2: CDC Data ==================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x2
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0xa CDC Data
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x5 Error Accessing String
ENDPOINT 0x2: Bulk OUT ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x2 OUT
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x0
ENDPOINT 0x82: Bulk IN ===============================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x82 IN
bmAttributes : 0x2 Bulk
wMaxPacketSize : 0x200 (512 bytes)
bInterval : 0x0
INTERFACE 3: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x3
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x6 Error Accessing String
ENDPOINT 0x85: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x85 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x40 (64 bytes)
bInterval : 0x2
ENDPOINT 0x5: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x5 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x40 (64 bytes)
bInterval : 0x2
>>> cfg =devs.set_configuration() -> Sets the configuration to active mode.
>>> intf = cfg[(0,0)] -> This is the interface, here interface 0.
>>> print(intf)
OUTPUT:
INTERFACE 0: Human Interface Device ====================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x2
bInterfaceClass : 0x3 Human Interface Device
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x4 Error Accessing String
ENDPOINT 0x81: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
ENDPOINT 0x1: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x1 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
>>> ep = usb.util.find_descriptor( intf, custom_match = lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_OUT)
>>> print(ep)
OUTPUT:
ENDPOINT 0x1: Interrupt OUT ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x1 OUT
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x400 (1024 bytes)
bInterval : 0x4
>>> ep.write('test')
ERROR:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\core.py", line 387, in write
return self.device.write(self, data, timeout)
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\core.py", line 948, in write
self.__get_timeout(timeout)
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\backend\libusb1.py", line 842, in intr_write
timeout)
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\backend\libusb1.py", line 920, in __write
_check(retval)
File "C:\Users\viswe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\usb\backend\libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error
I have tried to do everything from either side, but I haven’t understood why this is not working.
I am trying to use the dotnet libusb library again to find if that works, if I had done something wrong in the first trial.
Please let me know if you find I have understood something conceptually wrong. I am really concerned about the time I am spending on the USB connectivity problem, any help from your side is really appreciated.