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?