I'm trying to get a board containing LPC11U23 recognised as a generic HID Device. My code is based on the example provided on this site nxp_lpcxpresso_11u37_usbd_rom_hid_generic and nxp_lpcxpresso_11u14_lpcusblib_GenericHIDDevice at the link LPCOpen Software Development Platform LPC11XX . I used the same configuration as the first example with no success: the host device, which is a laptop, can't detect the USB device.
I'm using the functions provided in the USB on-chip drivers. USBD_API->hw->Init, USB_API->hid->Init run smoothly with no errors. The USBD_API->hw->Connect function is executed, and its results are visible in the DEVCMDSTAT register, where the DEV_EN, DCON and VBUSDEBOUNCED are high.
The PIO0_3/VBUS pin is set to function 0 as a general purpose pin, and the PIO0_6/USB_CONNECT pin is set to 1 to enable softConnect in the IOCON registers.
I've noted that the VBUSDEBOUNCED bit is set even if the device is not connected to host, even though the VBUS pin is low. I've also had problems in setting up the PLL.
static void usb_pin_clk_init(void)
{
/* power UP USB Phy and USB PLL */
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_USBPAD_PD);
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_USBPLL_PD);
/* enable PPL clock source */
Chip_Clock_SetUSBPLLSource(SYSCTL_PLLCLKSRC_MAINOSC);
/* enable USB main clock */
Chip_Clock_SetUSBClockSource(SYSCTL_USBCLKSRC_PLLOUT, 1);
while (!(LPC_SYSCTL->USBPLLCLKUEN & 0x01));
/*Power down PLL to change the PLL divider ratio */
Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_USBPLL_PD);
Chip_Clock_SetupUSBPLL(3,1);
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_USBPLL_PD);
while (!Chip_Clock_IsUSBPLLLocked()) {}
/* Enable AHB clock to the USB block and USB RAM. */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_USB);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_USBRAM);
}
In this function, the USB PLL never locks, and the device enters an infinite loop.
I've checked dmesg and wireshark usb packets in the host computer but there doesn't seem to be any sign of it being connected or enumeration starting. I've also tried connecting to another host, and using another USB cable.
What could be the reason of this?
Solved! Go to Solution.
At the end, I was able to solve both issues. There were two hardware issues: one was the lack of connectivity inside the USB connector, which I had to identify with physical means. After resolving that, I saw that the USB cable was malfunctioning. More important to this topic, when enumeration happened, I got this errors:
[ 4588.188847] usb 1-3: new full-speed USB device number 30 using xhci_hcd
[ 4588.303010] usb 1-3: device descriptor read/64, error -71
[ 4588.525032] usb 1-3: device descriptor read/64, error -71
[ 4588.747862] usb 1-3: new full-speed USB device number 31 using xhci_hcd
[ 4588.861997] usb 1-3: device descriptor read/64, error -71
[ 4589.083888] usb 1-3: device descriptor read/64, error -71
[ 4589.186147] usb usb1-port3: attempt power cycle
[ 4589.573867] usb 1-3: new full-speed USB device number 32 using xhci_hcd
[ 4589.574021] usb 1-3: Device not responding to setup address.
[ 4589.778190] usb 1-3: Device not responding to setup address.
[ 4589.986006] usb 1-3: device not accepting address 32, error -71
[ 4589.986129] usb 1-3: WARN: invalid context state for evaluate context command.
[ 4590.099968] usb 1-3: new full-speed USB device number 33 using xhci_hcd
[ 4590.100138] usb 1-3: Device not responding to setup address.
[ 4590.306165] usb 1-3: Device not responding to setup address.
[ 4590.513941] usb 1-3: device not accepting address 33, error -71
[ 4590.514039] usb 1-3: WARN: invalid context state for evaluate context command.
[ 4590.514098] usb usb1-port3: unable to enumerate USB device
This was due to a clock issue. While in the provided examples the Main Oscillator was powered on, and was set as the source of the system PLL, in the chip system initialization the main clock used the IRC. As a result, the USB PLL wasn't able to lock and successfully config, I wasn't able to switch to the main clock (which still wouldn't have worked for full-speed USB operation, without using the main oscillator), or use the USB PLL. Since the usb clock wasn't configured successfully, the USB wasn't able to operate.
If someone happens to have a similar problem, here are some troubleshooting steps:
I hope this will able to help someone with their USB issues.
At the end, I was able to solve both issues. There were two hardware issues: one was the lack of connectivity inside the USB connector, which I had to identify with physical means. After resolving that, I saw that the USB cable was malfunctioning. More important to this topic, when enumeration happened, I got this errors:
[ 4588.188847] usb 1-3: new full-speed USB device number 30 using xhci_hcd
[ 4588.303010] usb 1-3: device descriptor read/64, error -71
[ 4588.525032] usb 1-3: device descriptor read/64, error -71
[ 4588.747862] usb 1-3: new full-speed USB device number 31 using xhci_hcd
[ 4588.861997] usb 1-3: device descriptor read/64, error -71
[ 4589.083888] usb 1-3: device descriptor read/64, error -71
[ 4589.186147] usb usb1-port3: attempt power cycle
[ 4589.573867] usb 1-3: new full-speed USB device number 32 using xhci_hcd
[ 4589.574021] usb 1-3: Device not responding to setup address.
[ 4589.778190] usb 1-3: Device not responding to setup address.
[ 4589.986006] usb 1-3: device not accepting address 32, error -71
[ 4589.986129] usb 1-3: WARN: invalid context state for evaluate context command.
[ 4590.099968] usb 1-3: new full-speed USB device number 33 using xhci_hcd
[ 4590.100138] usb 1-3: Device not responding to setup address.
[ 4590.306165] usb 1-3: Device not responding to setup address.
[ 4590.513941] usb 1-3: device not accepting address 33, error -71
[ 4590.514039] usb 1-3: WARN: invalid context state for evaluate context command.
[ 4590.514098] usb usb1-port3: unable to enumerate USB device
This was due to a clock issue. While in the provided examples the Main Oscillator was powered on, and was set as the source of the system PLL, in the chip system initialization the main clock used the IRC. As a result, the USB PLL wasn't able to lock and successfully config, I wasn't able to switch to the main clock (which still wouldn't have worked for full-speed USB operation, without using the main oscillator), or use the USB PLL. Since the usb clock wasn't configured successfully, the USB wasn't able to operate.
If someone happens to have a similar problem, here are some troubleshooting steps:
I hope this will able to help someone with their USB issues.
The absence of the enumeration was caused by a hardware problem at the level of the USB micro connector, so even though all the necessary pins were configured and DP was active, the host wasn't able to detect the device. I still don't understand why the PLL doesn't lock. Is anyone able to help me with that?
Hello @fpinna
How about first checking the hardware, refer to schematic of lpcxpresso11u24.
Then try the demo under LpcOpen to see if the enumeration is successful.
BR
Alice
Hello @fpinna
How about firstly using USB logic analyzer analyze the USB package?
And Is usb device enumeration successfully on PC?
BR
Alice